SCO 2012: Running PowerShell Scripts via “Run Program Activity”


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 (

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

For example:

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.

By | 2013-04-12T14:19:29+00:00 April 12th, 2013|Automation|1 Comment

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (, Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (
  • SCU Europe 2014, 2015, 2016 (
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack


  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

One Comment

  1. Mr. Anderson January 19, 2017 at 22:45 - Reply

    PowerShell.exe -ExecutionPolicy Bypass -file “D:SCORCH_Scriptsremove-fromsccm.ps1” | exit

Leave A Comment