Azure PowerShell says
“execution of scripts is disabled on this system ”
I recently resumed work with Azure Powershell
and the first problem I encountered when I started to using PowerShell. The
first cmdlet resulted in error…..
Remediation - As an Administrator,
you can set the execution policy by typing this into your PowerShell window.
There are three options, but “remotesigned”
for current user will suffice. Avoid “unrestricted”, read more about the options,
follow the reference section.
set-executionpolicy remotesigned -Scope
CurrentUser
Check what you changed – should return
remotesiged.
Get-ExecutionPolicy
PS C:\Users\partha> Get-ExecutionPolicy
RemoteSigned
Okay one done..
to get into next, now my machine does not have TLS 1.2. Hence have to use to
allow SSL3, TLS1, TLS2. Just put
these all 3 as values
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Ssl3,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol
PS C:\Users\partha>
[System.Net.ServicePointManager]::SecurityProtocol
Ssl3, Tls
A sigh of
relief, all set to run the Azure Powershell but…. have to install the Azure
modules… thus have to install AZ modules
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201
-Force
Install-Module -Name PoweShellGet -Force
Install-Module -Name Az -AllowClobber
-Scope CurrentUser
Import-Module -Name Az
PS C:\Users\partha> Install-Module -Name Az -AllowClobber
-Scope CurrentUser
PS C:\Users\partha> Import-Module -Name Az
All AZ
modules resides here… check in spare time.
C:\Users\Documents\WindowsPowerShell\Modules
And then
finally can connect to Azure from PowerShell
Connect-AzAccount
Bingo!!!
Check
Powershell Version
$PSVersionTable.PSVersion
Major Minor Build
Revision
----- ----- -----
--------
5 1 17134
858
If you have queries, do drop in your queries below.
...HaPpY CoDiNg
Partha
References:
No comments:
Post a Comment