cls (Clear-Host) failes in AzureDevopsServer with version 2 of the task "PowerShell on Target Machines" with:
Exception setting "ForegroundColor": "Cannot convert null to type "System.ConsoleColor" due to enumeration values that are not valid. 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"."
My workaround is to just remove cls, since it's not really needed. Posting this mostly to save time for others since I could find nothing about this issue online, but also in case someone can actually explain why this is happening?
This has worked previous, but it's part of a process that we've not run for maybe 1,5 years. Since then of course a lot has happened. The target machine has been patched, but cls works fine if I remote desktop and run powershell locally so I think it's connected to powershell remoting or the AzureDevops task. Most likely the ADS task since last time we ran this it was on version 1 one the "PowerShell on Target Machines" task and probably also on our old TFS build server. It's still odd thou, since Clear-Host doesn't take any parameters, so where does the ForegroundColor come from?
Anyway, hope this helps someone save some time on troubleshooting if you run into this issue.