Reputation: 11
I am using a loop (ForEach-Object
) in a PowerShell script to connect to different hosts via plink (PuTTY).
plink -ssh $_ -l $user -pw $password -T -batch $command
$_
is the IP address of the host.
The command does an upgrade on the remote host. After the upgrade, the remote host reboots, but the connection doesn't close. So plink/PowerShell waits endlessly. How can I get PowerShell to resume the script?
Upvotes: 1
Views: 57
Reputation: 202504
You can solve this either on local/PowerShell side by aborting stalled command:
Powershell Start Process, Wait with Timeout, Kill and Get Exit Code
Or on remote side (assuming Linux), by running the command on background:
Run command on server using Plink and keep it running after disconnecting
You will find dozens of other questions here for both approaches.
Upvotes: 1