To install Azure CLI on PowerShell, perform the following steps:
In your PowerShell command prompt, execute the following command to download Azure CLI executable file:
PS C:\Users\TestUser> $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://azcliprod.blob.core.windows.net/msi/azure-cli-2.51.0.msi -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; Remove-Item .\AzureCLI.msi
Install Az PowerShell module.
PS C:\Users\TestUser> Install-Module Az
The latest version of the Az PowerShell module from the PowerShell repository is downloaded and installed.
Log in using your Azure account to start a CLI session.
PS C:\Users\TestUser> az login
Authorize your session.
Once the authorization is complete, you can access the Azure Portal. The session details appear in the PowerShell prompt.
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`. [ { "cloudName": "AzureCloud", "homeTenantId": "xxxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx", "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "isDefault": true, "managedByTenants": [], "name": "Eng Azure", "state": "Enabled", "tenantId": "xxxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx", "user": { "name": "[email protected]", "type": "user" } } ] PS C:\Users\TestUser>
Navigate to the downloaded
PS C:\Users\TestUser\Templates> Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
For more information, see here.