install Azure PowerShell on Windows10

get steps from https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-4.7.0, Installing the module for all users on a system requires elevated privileges. Start the PowerShell session using Run as administrator in Windows or use the sudo command on macOS or Linux:

1. install the Azure PowerShell:
if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
'Az modules installed at the same time is not supported.')
} else {
Install-Module -Name Az -AllowClobber -Scope AllUsers
}
2. run Connect-AzAccount to login
PS C:\Windows\system32> Connect-AzAccount
Connect-AzAccount : The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be
loaded. For more information, run 'Import-Module Az.Accounts'.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
3. run Set-ExecutionPolicy RemoteSigned to fix the issue
PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned
4. run Connect-AzAccount to login again:
PS C:\Windows\system32> Connect-AzAccount
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
zhuby1973@outlook.com Azure Pass - Sponsorship 2b73972d-b7ec-4ec6-a9ae-84471a4aacd7 AzureCloud
5. run Get-AzResourceGroup to get your ResourceGroup list
PS C:\Windows\system32> Get-AzResourceGroup -Name '*'
1. install the Azure PowerShell: if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) { Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' + 'Az modules installed at the same time is not supported.') } else { Install-Module -Name Az -AllowClobber -Scope AllUsers } 2. run Connect-AzAccount to login PS C:\Windows\system32> Connect-AzAccount Connect-AzAccount : The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'. At line:1 char:1 + Connect-AzAccount + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule 3. run Set-ExecutionPolicy RemoteSigned to fix the issue PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned 4. run Connect-AzAccount to login again: PS C:\Windows\system32> Connect-AzAccount Account SubscriptionName TenantId Environment ------- ---------------- -------- ----------- zhuby1973@outlook.com Azure Pass - Sponsorship 2b73972d-b7ec-4ec6-a9ae-84471a4aacd7 AzureCloud 5. run Get-AzResourceGroup to get your ResourceGroup list PS C:\Windows\system32> Get-AzResourceGroup -Name '*'
1. install the Azure PowerShell:
if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    Install-Module -Name Az -AllowClobber -Scope AllUsers
}

2. run Connect-AzAccount to login
PS C:\Windows\system32> Connect-AzAccount
Connect-AzAccount : The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be
loaded. For more information, run 'Import-Module Az.Accounts'.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

3. run Set-ExecutionPolicy RemoteSigned to fix the issue
PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned

4. run Connect-AzAccount to login again:
PS C:\Windows\system32> Connect-AzAccount

Account               SubscriptionName         TenantId                             Environment
-------               ----------------         --------                             -----------
zhuby1973@outlook.com Azure Pass - Sponsorship 2b73972d-b7ec-4ec6-a9ae-84471a4aacd7 AzureCloud

5. run Get-AzResourceGroup to get your ResourceGroup list
PS C:\Windows\system32> Get-AzResourceGroup -Name '*'

Leave a Reply

Your email address will not be published. Required fields are marked *