Hello,
I am working on a powershell script for Managing the Azure portal. Is it possible to check if the Add-AzureAccount -credentials session has expired or not.
I was using Get-AzureVM to check if the session is valid or not, but it gives me the following error and is not catchable in try and catch
Get-AzureVM : Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up yourAzure credentials.
At line:1 char:1
+ Get-AzureVM
+ ~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureVM], ArgumentException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand
Can anyone please help me on this. I want to run some scripts without much user interruption.
Also, I would like to avoid the use of AzurePublishSettingsFile.