Last active
February 14, 2017 20:48
-
-
Save kkamegawa/5f64d3909c83209df37c to your computer and use it in GitHub Desktop.
Choice Azure Subscription PowerShell Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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