I have a custom PowerShell deployment step that handles the deployment of SharePoint 2010 wsps included with my deployment package using the Microsoft.SharePoint.PowerShell snapin. This custom step executes fine on servers where the version of PowerShell that is installed is 2.0, but when the version of PowerShell that is installed is version 4.0 (as it is by default on Windows Server 2012 R2 machines) the script fails because PowerShell 4.0 uses version 4.0 of the .NET CLR which is incompatible with the SharePoint snapin.
I know that it is possible to run PowerShell 4.0 using the 2.0 engine by passing in the “-Version 2” parameter when launching PowerShell manually.
Is there some means to force the Octopus tentacle to launch PowerShell using the same parameter? Is there some alternative means available to force the tentacle to launch a specific version of PowerShell?
Thanks for reaching out and sorry for the delay here. The reason behind it was that we needed to discuss this one with the team in detail. You might be glad to hear that we added a feature to define the PS version that is already available in 3.3.13 which was released last night: https://github.com/OctopusDeploy/Issues/issues/2518
We’d be interested in knowing if this works for you.
Thanks so much for the update and for the fast turnaround!
We have a production release this weekend so I am going to hold off on the upgrade on Monday. I’ll let you know how it goes.
The release notes mention that the version is set via the “Octopus.Action.PowerShell.CustomPowerShellVersion” variable. How and where should this be done? Can you please clarify?
You need to create a variable called
Octopus.Action.PowerShell.CustomPowerShellVersion with the value
See attached screenshot
Is it necessary to upgrade both the Octopus server and the tentacle to 3.3.13 in order for this change to take effect?
I tried upgrading the tentacle only and that did not work. The tentacle still launched PowerShell 4.0 despite my creating a project-level variable named “Octopus.Action.PowerShell.CustomPowerShellVersion” with a value of 2.0.
Only the Tentacle should be enough. Though upgrading the server would allow you to upgrade all the Tentacles from the Environments page, which is quite handy.
Despite my project having an “Octopus.Action.PowerShell.CustomPowerShellVersion” variable with a value of 2.0 my script continues to run under PowerShell 4.0 and as such any attempts to call SharePoint cmdlets continue to error out.
I have completely uninstalled the previous version of the Octopus tentacle from my target server (including deleting the contents of the default install directory - C:\Octopus), rebooted, and installed version 3.3.13 of the tentacle software. After the install I rebooted the server again.
I modified my PowerShell script to include the following as the first line of the script:
Write-Host "PowerShell Version: " $PSVersionTable.PSVersion
When the tentacle runs the script the output continues to indicate that the current version is “4.0” and not the “2.0” that I specified in the variable.
My target server is running Windows Server 2012 R2. I have confirmed that the “Windows PowerShell 2.0 Engine” feature is installed and enabled and I have confirmed that if I launch PowerShell locally on the machine using the -Version 2.0 parameter that any scripts that are run will utilize PowerShell 2.0. My Octopus Deploy server has not yet been upgraded to 3.3.13 and is still running 3.2.24.
Please let me know if there is something else I should be doing to get the new functionality to work properly.
Hmm unless I’m terribly wrong, updating only Calamari should be enough. Unfortunately the dev that worked on this feature is asleep right now (he’s in Australia) and I can’t reach him.
Could you send me a full deployment log of a project that only has a step Powershell step with
Write-Host "PowerShell Version: " $PSVersionTable.PSVersion Instructions to get a full log with verbose values are below:
1) Add these 2 variables to your project http://docs.octopusdeploy.com/display/OD/Debug+problems+with+Octopus+variables
2) Create a new release (so the new variables take effect) and deploy it. If possible skip as many steps as you can and only leave step we are troubleshooting in order to avoid the noise in the log.
3) Send us the raw log of that deployment http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task
Hey there - I’ve consulted the Dev that worked in this feature and it turns out i was in fact, terribly wrong.
You do need to have the Octopus Server In ‘3.3.13’ to be able to use this feature.
Deep apologies for my mistake.
No need to send the log I asked in my previous reply.
Today I installed version 3.3.14 of Octopus Server and I confirmed that I am now able to target my scripts to execute using PowerShell 2.0. Thanks so much for incorporating this enhancement so quickly!