by CostasCosmas at 2013-04-12 14:20:08
I have a grid consisting of over 30 servers on which I remotely trigger a powershell script using its UNC path address location i.e. \\servername\something.ps1.
Every so often, some of these powershell scripts do not run and they are left in what looks to be a hanging state. You can see the scripts in Taskmgr.
I have checked the executionpolicy and it is set to bypass so there should be no issues there.
The very first thing that script is meant to do is to write an entry to a logfile which also resides at a unc path location. This log is never created so i only assume that the script never starts.
Can you please give me some idea as to how i go about debugging this issue?
Any ideas appreciated.
by RandomAdmin at 2013-04-14 11:21:19
I would open your script in Powershell ISE & insert some breakpoints in the script to see if you can pinpoint the problem as you step through the script.
by DexterPOSH at 2013-04-14 21:20:21
I have seen such a case, where in my script I used a mandatory parameter and forgot to supply argument to it. The script just hung for a while.
As RandomAdmin pointed out, you will have to debug it using ISE or other Script Editors on the machine where it is in hung state.
Hope this helps
by poshoholic at 2013-04-15 06:58:24
Another useful tip is to challenge all of your assumptions. Use additional logging or write events to an event log so that you can see what is going on. If script execution is the concern, and if you are invoking remote scripts from a main controller script, I would log something just before a remote script is invoked and as the first item in the remote script I would log something indicating that it got inside the remote script. Or add logic to test remote execution by having a second script that takes no parameters that simply logs something on the remote system, invoke that script first, and verify it executed successfully by checking for the presence of the log file entry. Something like that. When you invoke the script, if you pass it parameters, make sure you log those parameters and make sure the parameters are what you expect them to be. When you invoke your script on the remote system, make sure you invoke PowerShell with the -noninteractive parameter so that missing mandatory parameters result in errors instead of prompts (which would hang the script). Debugging might be helpful, but since this is intermittent, you really need additional troubleshooting logic in your script invocation so that you can catch what is going on.
by mjolinor at 2013-04-15 07:06:13
Might also consider running it as a job so that you can use receive-job to see if it's there's any clues in the ouput streams.
by CostasCosmas at 2013-04-15 13:08:09
Thanks for your useful replies.
Ill try and work out what is going and will come back and let you know when/if i find out what is going on.