function ssh-copy-id([string]$userAtMachine, [string]$port = 22) {
# Get the generated public key
$key = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
# Verify that it exists
if (!(Test-Path "$key")) {
# Alert user
Write-Error "ERROR: '$key' does not exist!"
}
else {
# Copy the public key across
& cat "$key" | ssh $userAtMachine -p $port "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
}
}