I want to create the AzureProfile.json file using the Az Module command in PowerShell, so that I can import the json file anytime I want to login to Azure to start\stop my VM's.
Below is the command\script I am using to create it but it is giving me error as shown in the screenshot.
I tried using the below code as well but it gives same error.
Connect-AzAccount -UseDeviceAuthentication
Save-AzProfile -path "$PSScriptRoot\AzureProfile.json"
WARNING: Unable to acquire token for tenant 'organizations' Connect-AzAccount : DeviceCodeCredential authentication failed: Retry failed after 4 tries.




From the error message, it looks like the authentication of your account is failing in the Browser pop-up that comes after
Login-AzAccount.I ran the first set of commands and it ran successfully.
Powershell:
Created File:
Note that my PowerShell version is
5.7.0.18831.