SCORCH: Run .NET Script With The Latest PowerShell Version

Orchestrator executes by default, it’s command in PowerShell 2.0 instead of using the latest PowerShell version installed on your system. It means that if you use the Run .Net Script Activity, Orchestrator will run your PowerShell commands in version 2.0 even if you have PowerShell v4 or v5 installed.

If you want to check which version your Orchestrator Server will use, you can create an easy runbook with a Net. activity:

orch1

Edit the task and type the following command:

$PSVer = $PSVersionTable.PsVersion

orch3

And go to “Published Data” and create the PSVer variable:

orch4

Now edit your runbook and select the following options:

orch2

Run the runbook and check result in “log history” tab:

orch5

OK, how to force Orchestrator to use the PowerShell version installed on the server?

That’s pretty simple, you must set the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\OnlyUseLatestCLR

  • Type : REG_DWORD
  • Value name : OnlyUseLatestCLR
  • Value Data : 1

Reboot your Orchestrator Server and run again your runbook:

orch6

 

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.