检查Azure资源组是否存在-Azure Powershell [英] Check If Azure Resource Group Exist - Azure Powershell
本文介绍了检查Azure资源组是否存在-Azure Powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图验证ResourceGroup是否存在,所以我认为以下代码应返回true或false,但不会输出任何内容.
I'm trying to verify if ResourceGroup exist or not so i thought that following code should return true or false, but it doesn't output anything.
$RSGtest = Find-AzureRmResource | Format-List ResourceGroupName | get-unique
$RSGtest -Match "$myResourceGroupName"
为什么我没有得到任何输出?
Why am I not getting any output?
推荐答案
更新:
您应该使用 AZ PowerShell模块 . :
You should use the Get-AzResourceGroup cmdlet from the new cross-plattform AZ PowerShell Module now. :
Get-AzResourceGroup -Name $myResourceGroupName -ErrorVariable notPresent -ErrorAction SilentlyContinue
if ($notPresent)
{
# ResourceGroup doesn't exist
}
else
{
# ResourceGroup exist
}
原始答案:
有一个 Get-AzureRmResourceGroup cmdlet:
There is a Get-AzureRmResourceGroup cmdlet:
Get-AzureRmResourceGroup -Name $myResourceGroupName -ErrorVariable notPresent -ErrorAction SilentlyContinue
if ($notPresent)
{
# ResourceGroup doesn't exist
}
else
{
# ResourceGroup exist
}
这篇关于检查Azure资源组是否存在-Azure Powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文