Functions/Get-ARMresourceList.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#Requires -Version 5.0 function Get-ARMresourceList { <# .SYNOPSIS Get a list of resource providers in Azure .DESCRIPTION Get a list of resource providers in Azure. The list is read from an cached file in the module (.\Data\allResources.json) See also Update-ARMresourceList cmdlet. .PARAMETER ResourceFile The path to a file that have the definition of the resource providers. .EXAMPLE Get-ARMresourceList .EXAMPLE Get-ARMresourceList -ResourceFile c:\temp\allResources.json .INPUTS PSCustomObject .OUTPUTS string .NOTES Author: Tore Groneng Website: www.firstpoint.no Twitter: @ToreGroneng #> [cmdletbinding()] Param( [string] $ResourceFile = (Split-Path -Path $PSScriptRoot -Parent | Join-Path -childpath Data | join-path -childpath allResources.json) ) $f = $MyInvocation.InvocationName Write-Verbose -Message "$f - START" Write-Verbose -Message "$f - Reading content from [$ResourceFile]" $jsonContent = Get-Content -Path $ResourceFile -Encoding UTF8 $allResources = $jsonContent | ConvertFrom-Json $list = New-Object -TypeName System.Collections.Generic.List[string] foreach ($Resource in $allResources) { $providerNameSpace = $Resource.ProviderNamespace foreach ($type in $Resource.ResourceTypes) { $fullNameSpace = "$providerNameSpace/$($type.ResourceTypeName)" $list.Add($fullNameSpace) } } $list Write-Verbose -Message "$f - END" } |