Reputation: 85
See my error photo above. I am running my powershell script in the Azure CLI. It outputs these errors and references a profile.ps1 script that I never created. I believe this has something to do with the first lines of code I run in the script. These are:
Install-Module AzureAD.Standard.Preview
Connect-AzAccount -UseDeviceAuthentication
Connect-AzureAD
Get-Module "PSCloudShellUtility"
Does anyone know why I would be getting these errors and how to fix it?
Thank you.
Upvotes: 0
Views: 128
Reputation: 8058
The issue might be related to the default "strict"
execution policy in Windows PowerShell, which is set to prevent the execution of untrusted scripts that could impact the Windows client environment. Retrieve the existing policies with the help of Get-ExecutionPolicy
PowerShell command and set it to unrestricted
it the policy is undefined.
Note: You can also try clearing the cache in the current user account and execute the script again. az cache purge
Refer MS Doc for execution policies.
Get-ExecutionPolicy -List
Use Set-ExecutionPolicy
policy to set it accordingly.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Saying that, I tried your script in my environment and everything was executing as expected.
Install-Module AzureAD.Standard.Preview
Connect-AzAccount -UseDeviceAuthentication
Connect-AzureAD
Get-Module "PSCloudShellUtility"
Output:
Upvotes: 0