Azure Custom PowerShell Script – Get Match Azure Resource from JSON File and Export it to CSV File

Sometimes if you want to find a data from the Azure resource JSON template file, for example, if it is virtual machine, you need to click for it one by one and then do some searching to find a specific value like the following example:

You finally find your target value in the export template JSON file, if you want to check which resource include your target specific value, you will in the trouble, because you need to click for each resource to search, think about you have thousand or million Azure resource?

Therefore, this post will guide you how to get Match Azure Resource from JSON File and Export it to CSV File by using our custom PowerShell script.

The steps for the whole process will be:

  1. Login Target Azure Tenant by using PowerShell
  2. Run the Custom Script

Step 1 – Login Target Azure Tenant by using PowerShell

Step 2 – Run the Custom Script

For example, if you want to get the VM list that specify their JSON file include value “grpazusoevmaimg” or ‘”BusinessUnit”: “test”‘, you can take the below example:

For Getting Resource Data part:

For Export to CSV part:

You can visit our SOS GitHub for downloading the source code as a template:https://github.com/SOSHKMVP/AzurePowerShell/blob/main/Get%20JSON%20resource%20and%20export%20to%20CSV/Get_Match_JSON_Data.ps1

Eric Chan
| + posts

Microsoft MVP
SOS Group Limited

Leave a comment

SOS Group Limited © 2024. All Rights Reserved.