I was trying to connect to Azure for the first time using power shell the other day and ended up with below error message.
Connect-AzAccount : The term 'Connect-AzAccount' 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.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [],
CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The command I was using to connect was Connect-AzAccount
When having such errors, the first thing you must check is if you ran power shell as administrator.
All other commands we're going to run below will only work if you ran power shell as administrator.
If Connect-AzAccount command didn't work even after running it as administrator try below commands to install and import Azure modules.
Install-Module -Name Az -AllowClobber
Import-Module Az
If these commands execute properly now you will be able to use Connect-AzAccount command as well.
But when I ran Install-Module -Name Az -AllowClobber command I got below error.
Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’
To fix this problem run below command to force to use TLS1.2
protocol[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
After running above command you should be able to run Install-Module -Name Az -AllowClobber command without any problem.
Don't forget to clear the session once you are done using Clear-AzContext command.
No comments:
Post a Comment