Listing Resources under Resource Group with Azure PowerShell

Simple task:  I want to list resources under a single ResourceGroup within one of the subscription.

This is an excuse to show how to login on different subscription and play a bit with the PowerShell Azure SDK.

First thing, start PowerShell Integrated Script Environment (ISE) with the Azure SDK loaded.


Login to your accounts…


This will prompt you to enter an ID + credentials.  Once you enter them, you should be in your subscription.

…  if you have more than one subscription?  Ok, that’s a little more complicated.

You need to find the subscription ID you are interested in.  Either go to to find it in the UI or…  use more PowerShell scripts:


Once you have your subscription ID, simply grab the ID and pass it to:

Add-AzureRmAccount –SubscriptionId <your subscription ID here>

This should prompt you again and afterwards, you’ll be in the context of the right subscription.

List resources under resource group

Now that you’re within the right subscription, let’s list the resource groups within that subscription:


This will give you the list of resources under that resource group.  Grab the resource group name and then you can list the resources underneath:

$res = Get-AzureRmResource | Where–Object {$_.ResourceGroupName –eq <You resource group name>}


That’s it!  I just wanted to get this ceremony out of the way.

You can build on that and use all different kind of cmdlets to query and manipulate your subscriptions.

11 thoughts on “Listing Resources under Resource Group with Azure PowerShell

  1. Try this-
    $groups = Get-AzureRmResourceGroup -Name
    foreach ($g in $groups)
    {Find-AzureRmResource -ResourceGroupNameEquals $g.ResourceGroupName | ForEach-
    Object {Get-AzureRmResource}}

  2. I want a list to get the list of resources along with the created by user details using power-shell.

    Possible to find?.

    1. This is kind of possible but not trivial. You see, “Created By” isn’t a property of the resource objects.

      The way to correlate the two would be to access the Activity Logs (see find the log entry for the resource creation and then you’ll find who did the REST action. From there you could query AAD to get details on that user (see

      On top of that, activity logs are available only for the last 30 days unless you redirect them to some other storage.

      So, not impossible, but not as simple as joining two tables in a db 😉

      Now, if that is important to your organization to, you could run a job every day to scan newly created resources and TAG those resources with some meta data about the creating user. Then it would be much easier to query the “created by” user, assuming nobody go and mess with the tags.

    1. You would need to use a where-clause and check the content of the resource group (see

      That will likely be slow since you’ll need to check the number of resources (API call) for each resource group.

      Alternatively, you can list all resources (with their resource group) and grab only the resource group name. Then compare that with the list of resource groups. You should find the ones that weren’t attached to any resources.

Leave a Reply to Vincent-Philippe Lauzon Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s