Skip to content

Instantly share code, notes, and snippets.

@marckean
Last active September 20, 2016 02:01
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 marckean/e85a2fedec425d76f0cdf68c7852aaba to your computer and use it in GitHub Desktop.
Save marckean/e85a2fedec425d76f0cdf68c7852aaba to your computer and use it in GitHub Desktop.
##########################################################################################
########################### Log into Azure using SPN ##############################
##########################################################################################
Write-Host "`nEnter credentials for the Azure Tenant.`n" -ForegroundColor Cyan
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$TenantID = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the Tenant ID", "Tenant ID")
$creds = Get-Credential
$MigrationAzure = Get-AzureRmEnvironment 'AzureCloud'
$MigrationEnv = Login-AzureRmAccount -Environment $MigrationAzure -TenantId $TenantID -Credential $creds -ServicePrincipal -Verbose
##########################################################################################
########################### Select Azure Subscription #############################
##########################################################################################
Select-AzureRmProfile -Profile $MigrationEnv
$MigrationSubscription = (Get-AzureRmSubscription | Out-GridView -Title "Choose an Azure Subscription ..." -PassThru)
$MigrationSubscriptionID = $MigrationSubscription.SubscriptionId
$MigrationSubscriptionName = $MigrationSubscription.SubscriptionName
##########################################################################################
######################### Azure Subscription Function #############################
##########################################################################################
Function AzureSubscription {
Select-AzureRmProfile -Profile $MigrationEnv
Get-AzureRmSubscription -SubscriptionName $MigrationSubscriptionName |
Select-AzureRmSubscription; Select-AzureSubscription -SubscriptionName $MigrationSubscriptionName}
##########################################################################################
######################### Select the Azure Subscription ###########################
##########################################################################################
AzureSubscription
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment