I had a strange error with the TFS / VSTeam Release Management and the ‘PowerShell on Target Machines’ task. The error only occurred in some environments:
2016-09-01T15:15:23.8214226Z ##[error]The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: Found value ‘aBcD’ with no corresponding key
‘aBcD’ were random characters that gave absolutely no results in google.
After a long analysis I finally found the solution in the diagnostics log on the build server:
15:15:23.799421 InputSessionVariables=$AppPoolPassword=ab,aBcD, $AppPoolUserName=customer\serviceuser 15:15:23.814424 System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Found value 'aBcD' with no corresponding key at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings) at Microsoft.TeamFoundation.DistributedTask.Handlers.PowerShellHandler.Execute(ITaskContext context, CancellationToken cancellationToken) at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.RunTask(ITaskContext context, TaskWrapper task, CancellationTokenSource tokenSource)
The problem was in one of the Session Variables of the ‘PowerShell on Target Machines’ task. I used a encrypted variable here to pass in a password. The password contained a comma and therefor was split in two parts and broke the syntax of the command.
I fixed this for now by removing the comma from the password – but I think it should be possible to enclose the variables in quotation marks. I will update this post if I find a syntax that works.
Update: You can’t just add quotation marks to the variables. I know there is some documentation that show it like this. But the quotation marks get passed with the value down to your script. So in your script you have to append a .Trim(“‘”) to your variable whenever you use it. I created an issue on github and it is supposed to be on the backlog.