Created
October 31, 2017 18:44
-
-
Save lukemurraynz/5ae952d2ad9eb2ee4cf84f362988e8a7 to your computer and use it in GitHub Desktop.
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 Connect-Azure | |
{ | |
<# | |
.SYNOPSIS | |
Connect-Azure Function to login to Azure - using Resource Groups. | |
.DESCRIPTION | |
Prompts for Azure user credentials, prompts to select Azure Subscription and passes through to select an Azure subscrption. | |
.EXAMPLE | |
Connect-Azure | |
.VERSION: 0.1 | |
#> | |
Import-Module -Name AzureRM | |
#Authenticate to Azure with Azure RM credentials | |
Add-AzureRmAccount | |
#Select Azure Subscription | |
Get-AZureRMSubscription|Out-GridView -PassThru|Select-AzureRmSubscription | |
} | |
Connect-Azure | |
$currentsub = (Get-AzureRmContext).Subscription | Select-Object -ExpandProperty Name | |
$rgs = (Get-AzureRmResourceGroup) | |
$results = @() | |
foreach ($rg in $rgs) | |
{ | |
$rg.ResourceGroupName | |
$tags = foreach ($tag in $rg.tags) | |
{ | |
$results += [pscustomobject]@{ | |
'Resource Group Name' = $rg.ResourceGroupName | |
'Tag Keys' = $tag.keys -join ',' | |
'Tag Values' = $tag.Values -join ',' | |
} | |
} | |
} | |
$results | |
$results | | |
ConvertTo-Html -As Table -Title "Microsoft Azure Resource Groups" -Head "<H1>$currentsub - Azure Resource Groups</H1>" -Body $Css | Out-File C:\temp\AzureRMResource.html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment