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
I have reproduced in my environment and got deleted results as you have got as below and I followed Microsoft-Document:
Then I used below command and then I have only got resources which are not deleted as below:
If you are still getting, then it might be soft deleted or not deleted, try to delete them and try the above command.