Create Resource Group with Powershell

This Script will ask login details and then sets the context for your subscription id. Then it tries to find Resource Group and if not found then it creates with the same name.

Login-AzureRmAccount
Set-AzureRmContext -SubscriptionId "your subcription id"
$ResourceGroupName='test-rg'
$Location='Southeast Asia'
$rg = Get-AzureRmResourceGroup -Name $ResourceGroupName -ErrorAction ignore
if(-not $rg)
{
   
          $rg= New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location -ErrorAction Stop
}

     

Comments