Public/Azure.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#requires -Version 3.0
#Requires -Modules Az.Accounts

function Choose-AzContext {
    <#
        .SYNOPSIS
        Lists availabe AzContext in lets the user choose on in a GridView. The selected AzContext will then be activated
        .DESCRIPTION
        Lists availabe AzContext in lets the user choose on in a GridView. The selected AzContext will then be activated
        .EXAMPLE
        Choose-AzContext
    #>

    [CmdletBinding()]
    param ()
    
    Write-Verbose "Listing existing AzContext ..."
    $newContext = Get-AzContext -ListAvailable | Out-GridView -Title "Choose an existing AzContext" -OutputMode "Single"

    Write-Verbose "Setting AzContext to $($newContext.Name) - $($newContext.Account) ..."
    Set-Azcontext -Context $newContext
}