访问ConvertTo-Html cmdlet

时间:2016-11-07 08:57:05

标签: powershell azure azure-powershell azure-resource-manager

如何在以下html表中添加值Sku.NameSku.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"

结果“temp.html”

List of Storage Accounts
ResourceGroupName:  "(my resourcegroup name)"
StorageAccountName: "(my storage account name)"
Sku:    Microsoft.Azure.Management.Storage.Models.Sku
Kind:   BlobStorage
Encryption: Microsoft.Azure.Management.Storage.Models.Encryption
AccessTier: Cool

预期

List of Storage Accounts
ResourceGroupName:  "(my resourcegroup name)"
StorageAccountName: "(my storage account name)"
Sku:    Microsoft.Azure.Management.Storage.Models.Sku
Sku.Name:   StandardLRS
Sku.Tier:   Standard
Kind:   BlobStorage
Encryption: Microsoft.Azure.Management.Storage.Models.Encryption
AccessTier: Cool

错误

尝试

-property (Sku).Name

导致:

+    -property (Sku).Name
+               ~~~
    + CategoryInfo          : ObjectNotFound: (Sku:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

1 个答案:

答案 0 :(得分:2)

您需要使用计算属性

<% b = Benchmark.measure do %>
  <% cache_if m.persisted?, m do %>
    <% puts '...Cache Invalidated. So Regenarated...' %>
    <div class="row meeting-top">...
    ...

  <% end -%>
<% end -%>

<% puts '-------------------------------' %>
<% puts 'Caching time:' %>
<% puts b %>
<% puts '-------------------------------' %>