I am seeing this error in Azure DevOps Pipelines when running an Azure PowerShell task as per the documentation here:
Error
The term 'd:\a\1\s' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
My pipeline YAML looks like this.
- task: AzurePowerShell@4
inputs:
azureSubscription: $(azureSub)
inline: 'New-AzResourceGroupDeployment -ResourceGroupName $(azureBroadsideResourceGroup) -TemplateFile .\build\arm-template_broadside-resources.json'
errorActionPreference: 'stop'
failOnStandardError: true
azurePowerShellVersion: 'latestVersion'
#scriptType: 'inlineScript' # Optional. Options: filePath, inlineScript
#scriptArguments: # Optional
#scriptPath: # Optional
#preferredAzurePowerShellVersion: # Required when azurePowerShellVersion == OtherVersion
The complete output of the task looks like this.
##[section]Starting: AzurePowerShell
==============================================================================
Task : Azure PowerShell
Description : Run a PowerShell script within an Azure environment
Version : 4.154.5
Author : Microsoft Corporation
Help : [Learn more about this task](https://go.microsoft.com/fwlink/?LinkID=613749)
==============================================================================
##[command]Import-Module -Name C:\Modules\az_2.3.2\Az.Accounts\1.6.0\Az.Accounts.psd1 -Global
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
##[command]Clear-AzContext -Scope Process
##[command]Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
##[command]Connect-AzAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud
##[command] Set-AzContext -SubscriptionId 33b17345-7dc8-4a49-81ae-4f29230e33b0 -TenantId ***
##[command]& 'd:\a\1\s'
##[command]Disconnect-AzAccount -Scope Process -ErrorAction Stop
##[command]Clear-AzContext -Scope Process -ErrorAction Stop
##[error]The term 'd:\a\1\s' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
##[section]Finishing: AzurePowerShell
It's interesting that its running & 'd:\a\1\s'
since that doesn't correspond to anything in the YAML to my eye. It smells a bit.