Created
March 7, 2023 06:16
-
-
Save vukasinterzic/15d171085e5d9d83d4ac51f5b18a0c80 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 Get-ExistingResourceTypeAndAbbreviation { | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$ResourceName | |
) | |
# Check if the resource exists | |
$resource = Get-AzResource -Name $ResourceName -ErrorAction SilentlyContinue | |
if (!$resource) { | |
Write-Error "Resource '$ResourceName' not found." | |
return | |
} | |
# Get the resource provider namespace | |
#$resourceId = $resource.ResourceId | |
$resourceType = $resource.ResourceType | |
# Get the abbreviation for the resource type | |
$abbreviation = $tableData | Where-Object Namespace -like $ResourceType | Select-Object -ExpandProperty Abbreviation | |
# Return the resource type and abbreviation as a PSCustomObject | |
return [PSCustomObject]@{ | |
ResourceType = $resourceType | |
Abbreviation = $abbreviation | |
} | |
} | |
#Example: | |
#Get-ExistingResourceTypeAndAbbreviation -ResourceName "VM-AzureIsFun" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment