I ran into a nasty little problem today in TeamCity 7.1 EAP whilst trying to get the PowerShell runner to execute a script but with PowerShell configured to run under .Net 4. If you’re not sure how to make PowerShell run using .Net 4 just do the following:
- In C:\WINDOWS\system32\WindowsPowerShell\v1.0 create a powershell.exe.config file
- Insert the following:
<configuration> <startup> <supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v4.0.30319"/> </startup> </configuration>
In TeamCity I have the the build runner configured is shown in the screen shot below:
When you try and run the runner this will result in an error like:
Step 2/2: Powershell [Step 2/2] Starting: C:\Windows\sysnative\cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command - <D:\TeamCity\buildagent\temp\buildTmp\powershell3310528665376175276.ps1 && exit /b %ERRORLEVEL% [Step 2/2] in directory: D:\TeamCity\buildagent\work\9572487a8041e395 [Step 2/2] The system cannot execute the specified program. [Step 2/2] Process exited with code 1[10:16:27] [Step 2/2] Step Powershell failed
Turns out it was a local problem on the server, powershell.exe.config was somehow corrupted!