Powershell 访问ConvertTo Html cmdlet中的嵌套属性
如何在下面的html表格中添加值Powershell 访问ConvertTo Html cmdlet中的嵌套属性,powershell,azure,azure-powershell,azure-resource-manager,Powershell,Azure,Azure Powershell,Azure Resource Manager,如何在下面的html表格中添加值Sku.Name和Sku.Tier $resourceGroupName = "(my resourcegroup name)" $storageAccounts = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName $storageAccounts ` | ConvertTo-Html ` -property ResourceGroupName, StorageAccountN
Sku.Name
和Sku.Tier
$resourceGroupName = "(my resourcegroup name)"
$storageAccounts = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName
$storageAccounts `
| ConvertTo-Html `
-property ResourceGroupName, StorageAccountName, Sku, Sku.Name, Sku.Tier, Kind, Encryption, AccessTier `
-body "<h2>List of Storage Accounts</h2>" `
-As List `
| Set-Content "temp.html"
预期
错误
尝试
-property (Sku).Name
结果:
+ -property (Sku).Name
+ ~~~
+ CategoryInfo : ObjectNotFound: (Sku:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
您需要使用计算属性:
-property ResourceGroupName, StorageAccountName, Sku, @{l='Sku Name'; e={$_.Sku.Name}}, @{l='Sku Tier'; e={$_.Sku.Tier}}, Kind, Encryption, AccessTier
+ -property (Sku).Name
+ ~~~
+ CategoryInfo : ObjectNotFound: (Sku:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-property ResourceGroupName, StorageAccountName, Sku, @{l='Sku Name'; e={$_.Sku.Name}}, @{l='Sku Tier'; e={$_.Sku.Tier}}, Kind, Encryption, AccessTier