代码之家  ›  专栏  ›  技术社区  ›  HariHaran

如何显示表powershell中的可用位置

  •  0
  • HariHaran  · 技术社区  · 6 年前

    您好,我使用PowerShell命令 Get-AzureRmLocation 列出azure中的可用位置。我希望以表格或某种格式良好的方式整齐地显示它们,而不是逐行列出它们。

    我试过了

    $locations = @(Get-AzureRmLocation | Select-Object -ExpandProperty DisplayName)
    Write-Host -ForegroundColor Yellow "Available Locations :" 
    $locations | Format-Table
    

    但这也列出了所有让屏幕看起来很长且不太好的东西。有办法吗?

    我得到的输出是这样一个列表 https://imgur.com/a/MjstD

    我希望它是一个包含所有可用位置的两表列,类似这样的内容。 谢谢

    3 回复  |  直到 6 年前
        1
  •  2
  •   Frode F.    6 年前

    这就是你想要的吗?

    $locations = Get-AzureRmLocation
    $locations | Format-Table @{n="Available Locations";e={$_.DisplayName}}
    
        2
  •  1
  •   Shui shengbao    6 年前

    也许您可以尝试以下示例:

    $locations = Get-AzureRmLocation
    
    $locations | Format-Table -Property Location,DisplayName
    

    我在实验室进行测试,结果如下: enter image description here

        3
  •  0
  •   ArtiomLK    3 年前

    要列出所有Azure位置,我建议使用 Get-AzLocation

    Get-AzLocation | Format-Table -Property Location, DisplayName
    

    结果: Get-AzLocation command output example

    PowerShell版本: PowerShell version