Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am planning to connect to remote Linux hosts via SSH and call scripts with Windows PowerShell SSH.

As far as I understand, if the SSH connection is lost (timeout or connection reset) whilst the script is running on the remote Linux node, the script will terminate.

So far I have implemented the following sequence:

  1. Initiate a connection to the host via SSH
  2. Once connected, run the script
  3. Script replies with a unique lock file location i.e. /var/tmp/job001.lock
  4. PowerShell script polls for existence of the file
  5. When the script completes, the lock file is removed
  6. When PowerShell script cannot detect lock file, it then continues

A failure is considered when:

  1. If it cannot reconnect after a number of attempts, the operations fails.
  2. If the script on the remote host takes too long to run, then we abort the operation.

This is my first PowerShell script, so has anything like this been done before?

If not, does the above seem sensible and any other recommendations (would using screen be more sensible)?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.