Many people have experienced problems when calling PowerShell.exe via the “Run Program Activity”
I hit the same problem today, and the solutions i have been using did not work for this particular script. (more info here)
After a couple of hours of testing, i realized the work around did not fx. when the script failed.
Luckily i found this post about VMware Orchestrator (http://wannemacher.us/?p=350)
It seems to be the same problem, so i tested it in SC Orchestrator and it worked.
I even seem to work in all situations and together with any script i tried!
When calling any powershell exe always use the following syntax:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -c "<insert poweshell script / command>" <insert arguments> 2>&1
UPDATE: when testing the old solution we have discovered that in some cases the above solution does not work.
Please use this updated solution:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -c "c:\SCO_Data\Scripts\SCSM-Get-FileAttachment.ps1" -Id "f3de3545-aa94-cda3-71c9-91533ea45e91" -ArchiveRootPath "C:\SCO_Data\Data\" <NUL 2>&1
Notice the <NUL 2>&1 in the end.
It sends all content from StdError to StdOut, which fixes the hang in the “Run Program Activity”
There are other options available as Eric describes in the VMware post:
Send to a specific file instead of StdOut:
Discard all error output:
Other problems can make this hang:
- Execution Policy
- Other Security
- Badly coded script
therefore another good idea is to set a time limit on the activity
I hope this bug will be fixed asap! until then we have to use this workaround.