Reputation: 123
I'm seeing some weird behavior when trying to use the AzurePowerShell@5 task in my ADO pipeline. Below is how I have the task configured:
- task: AzurePowerShell@5
inputs:
azureSubscription: 'xyz'
azurePowerShellVersion: LatestVersion
pwsh: true
ScriptType: filePath
ScriptPath: 'pathName'
ScriptArguments: >
(args)
Note that I set pwsh: true
which instructs the task to use PowerShell Core rather than Windows PowerShell. I have verified that the latest version of PowerShell 7 is installed by running winget install --id Microsoft.PowerShell
on the virtual machine that is used to run my pipeline. I also verified it was added to the System Path environment variable list correctly (C:\Program Files\PowerShell\7\
is in my path).
Despite all this, I am still getting the error message in the title:
The term 'pwsh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program
To add even more confusion, the same task works in a separate pipeline that uses a different virtual machine. The System PATH environment variable on both machines have PowerShell 7 and Windows PowerShell in the list. The only noticeable difference between the two machines is that the working machine is running Windows Server 2019 Standard, while the problematic machine is running Windows 10 Enterprise. Is Windows 10 Enterprise somehow incompatible with this task?
Any suggestions would be much appreciated!
Upvotes: 0
Views: 1999
Reputation: 46
Same issue here. Restarted the ADO Agent service. will solve the issue
This will (re)load recently updated environment variables. The path to pwsh.exe must be set in machines` PATH variable. This will normally be done by the powershell installer itself
BUT
already running agents will not be aware of that
-> RESTART service or interactive agent
Upvotes: 1
Reputation: 123
I managed to get this working. I'm not sure which of the suggestions below was the solution--perhaps it was a combination of some. Regardless, as suggested in the comments above, I
Upvotes: 0