Tuesday, 14 May 2019

PowerShell: Check whether Resource group exist or not.





Get-AzureRmResourceGroup -Name $rgName -ErrorVariable notPresent -ErrorAction SilentlyContinue
if ($notPresent)
{
    Write-Host 'ResourceGroup doesnt exist'
    # ResourceGroup doesn't exist
}
else
{
Write-Host 'ResourceGroup exist'
    # ResourceGroup exist
}

No comments:

Post a Comment