mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-24 08:53:59 +01:00
Renamed to enter-host.ps1 and wake-up-host.ps1
This commit is contained in:
parent
8186d08928
commit
8d659757cb
@ -1,12 +1,14 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Login to another host via SSH
|
Enter another host via SSH
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script logs into a remote host via secure shell (SSH).
|
This PowerShell script logs into a remote host via secure shell (SSH).
|
||||||
.PARAMETER remoteHost
|
.PARAMETER remoteHost
|
||||||
Specifies the remote hostname or IP address
|
Specifies the remote hostname or IP address
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./enter.ps1 linuxhost
|
PS> ./enter-host.ps1 tux
|
||||||
|
Entering 💻tux as user 'markus' using OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2
|
||||||
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -20,12 +22,11 @@ try {
|
|||||||
if ($IsLinux) { $username = $(whoami) } else { $username = $env:USERNAME }
|
if ($IsLinux) { $username = $(whoami) } else { $username = $env:USERNAME }
|
||||||
$username = $username.toLower()
|
$username = $username.toLower()
|
||||||
|
|
||||||
Write-Host "Trying to enter 💻$remoteHost as user '$username' using " -noNewline
|
Write-Host "Entering 💻$remoteHost as user '$username' 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 "$($username)@$($remoteHost)"
|
||||||
if ($lastExitCode -ne "0") { throw "'ssh -V' failed with exit code $lastExitCode" }
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
@ -12,7 +12,7 @@
|
|||||||
.PARAMETER numTimes
|
.PARAMETER numTimes
|
||||||
Specifies # of times to send the packet (3 by default)
|
Specifies # of times to send the packet (3 by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./wake-up.ps1 11:22:33:44:55:66 192.168.100.100
|
PS> ./wake-up-host.ps1 11:22:33:44:55:66 192.168.100.100
|
||||||
✅ Magic packet sent to IP 192.168.100.100, UDP port 9, 3x - wait a minute until the computer fully boots up.
|
✅ Magic packet sent to IP 192.168.100.100, UDP port 9, 3x - wait a minute until the computer fully boots up.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
Loading…
Reference in New Issue
Block a user