Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vukasinterzic/15d171085e5d9d83d4ac51f5b18a0c80 to your computer and use it in GitHub Desktop.
Save vukasinterzic/15d171085e5d9d83d4ac51f5b18a0c80 to your computer and use it in GitHub Desktop.
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