How to list all resources modified or accessed in last 90days

Microsoft

 

Hello, 

 

   I need to get all the resources which have been used or modified in last 90 days. In order to cut-off the cost of each subscription in azure. I need to develop script in PowerShell. The below one I tried which only show limited resources. 
If anyone knows how to do this, please let me know. Thanks in advance

Connect-AzAccount
Set-AzContext -Subscription '#subscription ID '
$logs = Get-AzLog  -StartTime (Get-Date).AddDays(-90)

$groups= $logs  | Where-Object {$_.Authorization.Action -like '*'} | Select-Object @{N="Caller";E={$_.Caller}}, @{N="Resource";E={$_.Authorization.Scope}}, @{N="Action";E={Split-Path $_.Authorization.action -leaf}},EventTimestamp, Status,CorrelationId  |
Sort-Object @{Expression = "Resource"; Descending = $false},@{Expression = "EventTimeStamp"; Descending = $false} | Group-Object Resource



 $all= $groups | ForEach-Object {$grp = $_.Group; $grp |Sort-Object | Select-Object -First 1  }
 
$all| Export-Csv -Path "#Path need to Set"s -Force -NoTypeInformation 

Write-Host "Total number of Resources modified = ($($all.Count))"

      

 

0 Replies