gpt4 book ai didi

powershell - 获取变量 Powershell 中资源组的位置值

转载 作者:行者123 更新时间:2023-12-03 04:46:26 25 4
gpt4 key购买 nike

我有一个 powershell 脚本来部署服务总线命名空间

这是我用来部署它的命令。

New-AzureRmServiceBusNamespace -ResourceGroup $ResourceGroupName -NamespaceName $ServiceBusNamespace -Location $Location

上述命令需要输入位置参数。我希望该位置值作为我的资源组所在的位置。如何提取资源组的位置值?

尝试了各种方法,都失败了。当我尝试此操作时,它显示 @{location=west us}

$location = Set-AzureRmResourceGroup -Name $ResourceGroupName -Tag @{} | Select-Object Location

Write-Host $location

需要帮助。谢谢!

最佳答案

$loc = Get-AzureRMResourceGroup -Name $ResourceGroupName | select-object -expandproperty location

好吧,如果你想GET某些东西,请使用适当的动词。或者像这样:

$rg = Get-AzureRMResourceGroup -Name $ResourceGroupName
$rg.location

关于powershell - 获取变量 Powershell 中资源组的位置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48416476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com