Orchestrator: How to use the Windows native powershell version
Introduction
Since System Center Orchestrator uses PowerShell version 2.0 it can become troublesome for some, especially when they want to run scripts or the integrated Run .Net Script activity in Orchestrator.
There's at least two methods of doing this, one by editing in the Windows registry or by calling PowerShell from outside of Orchestrator.
Checking the current PowerShell version in Orchestrator
Let's make sure first what version of PowerShell Orchestrator is using before making any changes.
Create a runbook.
Add a Run .Net Script activity which can be found under the System activities.
https://gallery.technet.microsoft.com/site/view/file/199099/1/pic1.png
Edit the Run .Net Script activity and change the Type to PowerShell.
In the Script block we want to make a variable that will contain the PowerShell version.
https://gallery.technet.microsoft.com/site/view/file/199100/1/pic2.png
Navigate to **Published Data **to create the same named variable (**String **variable) as you did in the script block and then press Finish.
https://gallery.technet.microsoft.com/site/view/file/199101/1/pic3.png
To get the information about this variable we will need to enable extended logging, you can do this by **right clicking **your runbook and then choose Properties.
https://gallery.technet.microsoft.com/site/view/file/199102/1/pic4.png
Then navigate to the **Logging **tab, make sure to check the following box: Store Activity-specific Published Data and then press Finish.
https://gallery.technet.microsoft.com/site/view/file/199104/1/pic5.png
Run your runbook once, when the runbook has run you should see Successful event in the Log History at the bottom.
Now open the log by double clicking the log entry in the Log History, a new window should open up.
https://gallery.technet.microsoft.com/site/view/file/199105/1/pic6.png
Double click the entry again and scroll down to the bottom until you find your variable name.
https://gallery.technet.microsoft.com/site/view/file/199106/1/pic7.png
As you can see the value is displayed as 2.0 which means Orchestrator is currently running PowerShell version 2.0.
Now let's go through the first method to force Orchestrator to use Window's native PowerShell version.
Method 1
Go to **Start **and then type Regedit and press Enter.
https://gallery.technet.microsoft.com/site/view/file/199107/1/method1_1.png
Go to the following registry path:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework
https://gallery.technet.microsoft.com/site/view/file/199108/1/method1_2.png
Create a new entry by right clicking the .NETFramework folder and choose **New **-> DWORD (32-bit) Value.
https://gallery.technet.microsoft.com/site/view/file/199109/1/method1_3.png
Set the value name to: OnlyUseLatestCLR
**
**https://gallery.technet.microsoft.com/site/view/file/199110/1/method1_4.pngSet the value data to: 1
**
**https://gallery.technet.microsoft.com/site/view/file/199111/1/method1_5.pngNow restart your Orchestrator server.
Once you have restarted your Orchestrator server, re run your runbook that you previously created and see what version it will give.
**My result:
**https://gallery.technet.microsoft.com/site/view/file/199112/1/pic8.png
The second way of making Orchestrator use the Windows native PowerShell version is by calling PowerShell from within the Run .Net Script activity.
Method 2
Create a new runbook.
Add a Run .Net Script activity which can be found under the System activities.
https://gallery.technet.microsoft.com/site/view/file/199113/1/pc1.png
Edit the Run .Net Script activity and change the Type to PowerShell.
In the Script block we will call powershell.exe from outside by writing the following:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -command "&{C:\Scripts\YourScriptHere.ps1}"
https://gallery.technet.microsoft.com/site/view/file/199115/1/pc2.png
Change the path to correspond where your PowerShell scripts are located and then insert your script name at the end.
Now just Check In your runbook and run it!
You can also download the guide in PDF version here.