VSTS Release – PowerShell on Target Machines Quirk

I ran into an obscure issue when porting my PowerShell deployment code across to the new VSTS web-based release management (the release management tool that comes with Team Foundation Server 2015 update 2). To all intents and purposes, there was nothing wrong with the script or the connection – I could run the script on the deployment (remote) machine with no errors, and I could execute a simple “Hello World” script from the deployment agent on the deployment machine.

In the end, I had to capture the exception on the deployment (remote) machine and output it to a file to find the underlying issue. This returned me:

Exception setting “ForegroundColor”: “Cannot convert null to type “System.ConsoleColor” due to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are “Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White”

Which I could not figure out! It turned out after trial and error, that I had a clear console (cls) command in my script which was failing as there is technically no console to clear when executing remotely and capturing the return value in the way the VSTS task does. I hope this saves someone time and pain!



Tagged: Powershell, TFS Release,
Categorised: Team Foundation Server, VSTS,
By:
On: