Skip to content

Instantly share code, notes, and snippets.

@RaccoonDev
Created April 21, 2015 20:16
Show Gist options
  • Save RaccoonDev/1e65d93ae1f006803fd2 to your computer and use it in GitHub Desktop.
Save RaccoonDev/1e65d93ae1f006803fd2 to your computer and use it in GitHub Desktop.
Add-AzureAccount with stored credentials
<#
# Create PWD File with this command:
# Read-Host -AsSecureString | ConvertFrom-SecureString | out-file <<<PATH_TO_FILE>>>
You can find instructions how to add deployment user to your subscription here:
http://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/
#>
$pwdFilePath = "<<<PATH_TO_FILE>>>"
if(!(Test-Path $pwdFilePath)) { throw "PWD File not found"; }
$username = "<<<AZURE_USER_NAME>>>";
$password = cat $pwdFilePath | ConvertTo-SecureString;
$deploymentCreds = New-Object System.Management.Automation.PSCredential($username, $password);
Add-AzureAccount -Credential $deploymentCreds;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment