I am trying to get list of all non-compliant resources from Azure for a certain management group. For that I am using below Powershell query, but it seems the result is getting limited to 1000 records, so I am not getting all the records. In the management group there are around 9 K non-compliant resources. Is there a way to set pagination or download all the resource records.
$policyEvents = Get-AzPolicyState -ManagementGroupName "Test" -Filter "ComplianceState eq 'NonCompliant'"
$policyEvents | ConvertTo-Csv | Out-File 'mggroup.csv'