mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-04 20:09:22 +01:00
Updated enter.ps1
This commit is contained in:
parent
21e8911239
commit
c13e3c3dbd
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
SSH login to another host
|
||||
Login to another host via SSH
|
||||
.DESCRIPTION
|
||||
This PowerShell script logs into another host by SSH.
|
||||
This PowerShell script logs into a remote host via secure shell (SSH).
|
||||
.PARAMETER remoteHost
|
||||
Specifies the remote hostname or IP address
|
||||
.EXAMPLE
|
||||
@ -20,9 +20,12 @@ try {
|
||||
if ($IsLinux) { $username = $(whoami) } else { $username = $env:USERNAME }
|
||||
$username = $username.toLower()
|
||||
|
||||
Write-Host "Entering remote host '$remoteHost' as user '$username' using " -noNewline
|
||||
Write-Host "Trying to enter 💻$remoteHost as user '$username' using " -noNewline
|
||||
& ssh -V
|
||||
if ($lastExitCode -ne "0") { throw "'ssh -V' failed with exit code $lastExitCode" }
|
||||
|
||||
& ssh "$($username)@$($remoteHost)"
|
||||
if ($lastExitCode -ne "0") { throw "'ssh -V' failed with exit code $lastExitCode" }
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user