Skip to content

Instantly share code, notes, and snippets.

@kkamegawa
Last active February 14, 2017 20:48
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 kkamegawa/5f64d3909c83209df37c to your computer and use it in GitHub Desktop.
Save kkamegawa/5f64d3909c83209df37c to your computer and use it in GitHub Desktop.
Choice Azure Subscription PowerShell Script
function Choice-AzureSubscription
{
$appdata = [environment]::GetFolderPath("Applicationdata")
$jsonFile = Join-Path $appdata -childpath "Windows Azure Powershell" | join-path -ChildPath "AzureProfile.json"
$json = get-content $jsonFile -encoding UTF8 -raw | ConvertFrom-Json
if($json.Subscriptions.Count -gt 1) {
for($index = 0;$index -lt $json.Subscriptions.Count;$index++){
write-host $index ":" $json.Subscriptions[$index].Name
}
$subscriptionIndex = Read-Host "Select Azure Subscription "
if($subscriptionIndex -le $json.Subscriptions.Count -and $subscriptionIndex -ge 0) {
Select-AzureSubscription $json.Subscriptions[$subscriptionIndex].Name
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment