This Azure tutorial will discuss the syntax and usage of New-AzResourceGroup PowerShell Command with examples.
Table of Contents
New-AzResourceGroup
This PowerShell command helps you Create an Azure resource group.
Syntax of New-AzResourceGroup
New-AzResourceGroup
[-Name] <String>
[-Location] <String>
Example – Create a new Resource Group
The below PowerShell command will create a new Resource Group named as “mynewresgroup123” on the location “West US”.
New-AzResourceGroup -Name "mynewresgroup123" -Location "West US"
But after executing the above PowerShell command, I got the below error.
The ‘New-AzResourceGroup’ command was found in the module ‘Az.Resources’, but the module could not be loaded. For more information, run ‘Import-Module Az.Resources’.
Check out the same error the below screen shot.

Now, to fix this error, I need to import the Az. Resources module. Below is the command I need to execute to do so.
Import-Module Az.Resources
Then I reran the below PowerShell command.
New-AzResourceGroup -Name "mynewresgroup123" -Location "West US"
It is asking to connect to the Azure Run Connect-AzAccount to login

Now, you can run the below command to connect to Azure from PowerShell.
Connect-AzAccount
It will ask you to enter your username and password and then show your subscription details.

Now rerun the below PowerShell command to create the resource group and the command has been executed successfully. Check out the below screenshot.
New-AzResourceGroup -Name "mynewresgroup123" -Location "West US"

You may like the following Azure tutorial:
- The term ‘New-AzResourceGroup’ is not recognized as the name of a cmdlet
- New-AzResourceGroup: A positional parameter cannot be found that accepts argument
In this Azure tutorial, we discussed the syntax and usage of New-AzResourceGroup PowerShell Command with examples.
I am Bijay, a Microsoft MVP (10 times) having more than 17 years of experience in the software industry. During my IT career, I got a chance to share my expertise in SharePoint and Microsoft Azure, like Azure VM, Azure Active Directory, Azure PowerShell, etc. I hope you will learn from these Azure tutorials. Read more