For some reason I run into an issue today when I was creating this blogpost where after signing in with PowerShell to Azure with Connect-AzAccount I was unable to run any other commands. I have tried all different kind of possible solution, from clearing cache, temp folders, reboot, installing updates etc. but none of these was the solution to this.
After a while of troubleshooting I remembered that with AzureRm I did have this issue aswell. Clearing the Azure Profile was the solution for this. For Az there is still such a command, ‘Clear-AzContext’.
PS C:\Users\HeyAzureGuy> Connect-AzAccount -Tenant '***'
Account; SubscriptionName; TenantId; Environment
email@example.com; HeyAzureGuy; ***; AzureCloud
PS C:\Users\HeyAzureGuy> Get-AZRoleAssignment
Get-AZRoleAssignment : Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials.
At line:1 char:1
+ CategoryInfo : CloseError: (:) [Get-AzRoleAssignment], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.GetAzureRoleAssignmentCommand
Run the Clear-AzContext Commandlet and then try Connect-AzAccount to get the valid bearer token to continue.
PS C:\Users\HeyAzureGuy> Clear-AzContext -Force
Have a cloudy day!