首页 > 解决方案 > 使用 Get-AzLocation 选择特定的 Azure 位置

问题描述

我正在尝试找到一种使用 Azure PowerShell 选择目标 Azure 位置(对象)的方法。

这给了我位置列表:

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

如何选择其中 1 个,例如...

$Location = Get-AzLocation -Something "South Central US"

标签: azurepowershell

解决方案


您可以Where-Object用来过滤DisplayName

❯ Get-AzLocation | Where-Object {$_.DisplayName -eq "South Central US"}

Location    : southcentralus
DisplayName : South Central US
Providers   : {Microsoft.Automation, Microsoft.Storage, Microsoft.Network, Microsoft.Compute…}

这将返回一个类型的对象Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResourceProviderLocation


推荐阅读