Quantcast
Channel: Azure Management Portal forum
Viewing all articles
Browse latest Browse all 4189

Is it possible to check if Add-AzureAccount login session has expired or not

$
0
0

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 your
Azure 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.



Viewing all articles
Browse latest Browse all 4189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>