Skip to content

Instantly share code, notes, and snippets.

@astaykov
Created August 13, 2014 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astaykov/4805e070a3ad47a883da to your computer and use it in GitHub Desktop.
Save astaykov/4805e070a3ad47a883da to your computer and use it in GitHub Desktop.
Non-interactive Azrue PowerShell management
# first save encrypted password to a file that can later be used
read-host -assecurestring | convertfrom-securestring | out-file d:\tmp\securestring.txt
# then use the saved password
$password = cat d:\tmp\securestring.txt | convertto-securestring
# currently (August, the 13nd, 2014) only organizational accounts are supported (also with custom domain).
# Microsoft Accounts (Live ID) are not supported
$username = "user@tenant.onmicrosoft.com" # or user@yourdomain.com if 'yourdomain.com' is registered with AAD
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password
Add-AzureAccount -credential $mycred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment