Renamed to enter-host.ps1 and wake-up-host.ps1

This commit is contained in:
Markus Fleschutz 2024-10-14 11:38:09 +02:00
parent 8186d08928
commit 8d659757cb
2 changed files with 6 additions and 5 deletions

View File

@ -1,12 +1,14 @@
<#
.SYNOPSIS
Login to another host via SSH
Enter another host via SSH
.DESCRIPTION
This PowerShell script logs into a remote host via secure shell (SSH).
.PARAMETER remoteHost
Specifies the remote hostname or IP address
.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
https://github.com/fleschutz/PowerShell
.NOTES
@ -20,12 +22,11 @@ try {
if ($IsLinux) { $username = $(whoami) } else { $username = $env:USERNAME }
$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
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])"

View File

@ -12,7 +12,7 @@
.PARAMETER numTimes
Specifies # of times to send the packet (3 by default)
.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.
.LINK
https://github.com/fleschutz/PowerShell