-
Notifications
You must be signed in to change notification settings - Fork 7
/
AzureResourceCount.ps1
41 lines (30 loc) · 950 Bytes
/
AzureResourceCount.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
.AUTHOR: Luke Murray (Luke.geek.nz)
.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
$resources = Get-AzureRMResource | Select-Object ResourceType
$results = @()
foreach ($resource in $resources)
{
$a = Get-AzureRmResource -ResourceType $resource.ResourceType
$results += [pscustomobject]@{
'Count' = $a.Count
'Resource' = $resource.ResourceType
}
}
$results | export-csv c:\temp\AzureResources.csv