Fixed enter-host.ps1

This commit is contained in:
Markus Fleschutz 2024-10-30 12:58:00 +01:00
parent b6e703d96e
commit 6419712ff2

View File

@ -27,14 +27,14 @@ try {
$remoteUser = $(whoami) $remoteUser = $(whoami)
} else { } else {
$remoteUser = $env:USERNAME $remoteUser = $env:USERNAME
$remoteUser = $remoteUser.toLower()
} }
$username = $username.toLower()
Write-Host "⏳ Connecting to '$remoteHost' as user '$username' using " -noNewline Write-Host "⏳ Connecting to '$remoteHost' as user '$remoteUser' using " -noNewline
& ssh -V & ssh -V
if ($lastExitCode -ne "0") { throw "'ssh -V' failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'ssh -V' failed with exit code $lastExitCode" }
& ssh "$($username)@$($remoteHost)" & ssh "$($remoteUser)@$($remoteHost)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"