(Please redirect to the correct help forum if this is not the right place)
I am running a simple PowerShell script to retrieve details of Resource Groups from a subscription and exporting these to a .cvs file.
The script is working fine to pull out all the details required except that the Tags column only displays “System.Collections.Harshtable”, instead of the actual tags that I am interested in.
I have tried googling around and the suggestions I am getting are to use:
- GetEnumarator or
- GetMember commands.
But I think I am not using the correct syntax for these commands, as I still do not get the two tags that I am looking for.
However, when I run the Get-AzResource command manually per subscription without exporting to a .cvs file, the name/value pairs are all listed correctly per resource group, except that the resources are NOT listed in a table.
Below is the sample code that I am running:
# Get Subscription List
$Subscriptions = Get-AzSubscription
# Go through each subscription
foreach ($Subscription in $Subscriptions)
{
# Check wheather the subscription is active
if ($Subscription.State -ne "Disabled")
{
# Change Azure context to current subscription
Set-AzContext -SubscriptionId $Subscription.Id | out-null
$ctx = Get-AzContext
Write-Output "Script is now procesing resources from '$($ctx.Subscription.Name)' subscription"
# Get list of Specific Azure Resources
$AzureResources = Get-AzResource -ResourceType "Microsoft.Databricks/workspaces"
foreach ($Resource in $AzureResources)
{
Get-AzResourceGroup | Select-Object -Property ResourceGroupName, Location, ProvisioningState, Tags |
Export-Csv C:\Temp\DatabricksTags.csv -NoTypeInformation
}
}
)
The CSV Output file from the above is as follows:
ResourceGroupName, Location, ProvisioningState, Tags
1.ResourceGroup1, Location1, Successful, System.Collection.Harshtable
- etc
I am looking for an easy way to enumerate two tags from the above Harsh table instead of it just printing out System.Collection.Harshtable
Thanks in advance for any guidance
Top comments (0)