skip to Main Content

I have an issue at PowerShell script for executing on pipeline at dev azure,
error is happening with message:
Start-Process : This command cannot be run due to the error: %1 is not a valid Win32 application

it was worked some time ago but now it is not, is it some updates were done on azure?
or I need to improve some code?

 foreach ($alert in $alerts)
    {
        Write-Log "`tCreating alert $($alert.AlertName)"
        $azArgs = "monitor metrics alert create --name ""$($alert.AlertName)"" --resource-group ""$($resourceGroup)"" --condition ""$($alert.AlertRule)"" --scopes ""$($alert.ResourceId)"" --window-size 5m --evaluation-frequency 1m --action ""$actionGroupResourceId"" --description "" "" --subscription ""$subscriptionId"" --auto-mitigate true"
        Write-Verbose $azArgs
        Start-Process "az" -ArgumentList $azArgs -NoNewWindow -Wait
    }

2

Answers


  1. Chosen as BEST ANSWER

    issue is related to azure updates https://pullanswer.com/questions/error-with-startprocess-and-az-command

    problem is Azure Cli has been updated and so now there is an az.ps1 so i need to make "az.cmd" in order to continue to call the good program...


  2. Start-Process : This command cannot be run due to the error: %1 is not a valid Win32 application

    AFAIK, the issue shows that you are not using X32 environment. so, that the error thrown. It is a common issue we cannot directly find out what exactly happens we can fix it by following

    Ways to fix:

    1. Try to uninstall and install the PowerShell Az module.
    2. Update the PowerShell Az module with latest version
    3. Check your Dev environment has X64. If it is X64 make sure to install the PowerShell Module Globally.
    4. It may happen sometimes with you are passing environment variable path make sure to double check once.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search