Hello @Lesiba A. Serite ,
I am just trying to expand Ravikanths answer with couple of guidelines and with sample cmdlets so that you can get started , please see the comments for each line so that you can understand better and expand it accordingly !
$Resources = Get-AzureRmResource #It will give all the resource names
foreach($resource in $Resources) #looping through each resource
{
if ($resource.ResourceType -eq "Microsoft.Compute/virtualMachines") # if the resource type is VirtualMachines
{
Get-azvm -resourcegroupname $resource.ResourceGroupName -Name $resource.Name #Call get-azVM to get VM details
}
elseif ($resource.ResourceType -eq "Microsoft.Storage/storageAccounts") # if the resource type is StorageAccounts
{
Get-AzureRmStorageAccount -resourcegroupname $resource.ResourceGroupName -Name $resource.Name #Get the details of storage account
}
}
Sample Output
VM Details
Storage Details:
Get-AzureRMResource cmdlet returns lot of information , so you can filter it out by selecting the particular column
In the above code, you can always narrow down to only specific attributes:
For example : for storage to get the particular storage account information:
$str = Get-AzureRmStorageAccount -resourcegroupname "rgname" -Name "accountname"
if you want to query specific attribute you can use $str.kind , $str.SkuName etc.
Above script is querying only for VMs , Storage Accounts based upon the if condition - you can expand the script based upon your requirements !