Get-AzureRmResource showing up the deleted resources also

380 views Asked by At

I am creating a powershell script using Azure CLI where I am using Get-AzureRmResource command to fetch all the resources in a subscription.

This command is giving the details of deleted resources also , which are not longer in Azure portal as well. How can I get only those resources which are present in the portal

1

There are 1 answers

3
RithwikBojja On

I have reproduced in my environment and got deleted results as you have got as below and I followed Microsoft-Document:

enter image description here

Then I used below command and then I have only got resources which are not deleted as below:

Get-AzResource   | Where {$_.Name -Notlike 'failure*'} | ft

enter image description here

If you are still getting, then it might be soft deleted or not deleted, try to delete them and try the above command.