auto login Azure powershell

Question:

Every time I open a azure powershell windows is it possible to auto login ?

i.e. this command given below should run everytime I open Azure Command window.

Get-AzurePublishSettingsFile (path in local machine)

or even
Add-AzureAccount

Answer:

You can actually do it. Follow this process:

Open the Azure PowerShell initialization file at “C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\ShortcutStartup.ps1” for 64-bit OS or “C:\Program Files\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\ShortcutStartup.ps1” for 32-bit OS.

Add the following code just after the statement $VerbosePreference="Continue"

That should do the auto login for you

@Update: For Azure ARM mode, the command would be Login-AzureRMAccount -Credential $cred. This might not work with Microsoft accounts though.

Source:

auto login Azure powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply