The simplest answer is that powershell can just invoke the built-in ssh.exe like other shells would:
# restart remote server over SSH:
ssh.exe user@hostname shutdown -r -t 0
A longer answer is that powershell 6+ can use the SSH protocol to establish remote powershell sessions, which have some more features than plain SSH. See PowerShell remoting over SSH for details, but the basics are:
- Powershell 6+ must be installed on both the local and remote systems
- On the remote server, an SSH subsystem for powershell should be running
- Commands that use PS Remoting like
Invoke-Command can use this directly by specifying -HostName instead of -ComputerName.
- Requirements are the same for linux and windows clients/servers (in case you're running powershell on linux)
When it's configured properly, you can restart a remote server using SSH like:
Invoke-Command -HostName MyServer -UserName MyUser -ScriptBlock {Restart-Computer}
and manually check for the remote server to come back up like:
Sleep 30 ## wait before checking
$SSH=$null
While(-not $SSH){
Try {$SSH = New-PSSession -HostName 'MyServer' -ea Stop}
Catch{Write-Host 'Waiting for reboot...'}
sleep 10
}