1. In the first, you have to make sure that you have the right version of “PowerShellGet” you can make sure of that by running the below command, and the result must match the below screenshot.
Get-Module PowerShellGet -list | Select-Object Name,Version,Path
2. Rerun PowerShell but with Administrator privileges.
3. Run the below command to start the installation process of Azure PowerShell.
Install-Module AzureRM -AllowClobber
It will ask if you would like to download from Powershell gallery, select yes to All.
4. Change the Execution Policy to remoteSigned and import the module:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned Import-Module AzureRm
The whole process will be:
5. Test with login and some commands:
If you have created Azure VM in the portal, try command Get-AzureRmVM.
Then you can logout by command : Disconnect-AzureRmAccount