I created a custom object
$customsa = New-Object -TypeName psobject
$customsa | Add-Member -MemberType NoteProperty -Name Name -Value (Get-AzStorageAccount).StorageAccountName
$customsa | Add-Member -MemberType NoteProperty -Name Tier -Value (Get-AzStorageAccount).AccessTier
$customsa | Add-Member -MemberType NoteProperty -Name Replication -Value (Get-AzStorageAccount).sku.Name
$customsa | Add-Member -MemberType NoteProperty -Name AccountKind -Value (Get-AzStorageAccount).kind
$customsa | Add-Member -MemberType NoteProperty -Name ResourceGroupName -Value (Get-AzStorageAccount).ResourceGroupName
The output is an array format
However I want the output to show in a table format like this
Thanks
2
Answers
Have you tried?:
From your example:
Get-AzStorageAccount
is returning all of your storage accounts each time you run it so you are assigning the value of all storage accounts to each property when you’re usingAdd-Member
.You should be able to get the same result using
Select-Object
which will create yourpsobject
for you