Search code examples
azure-active-directory

List all soft deleted users from Azure AD directory


Command let provided by MS has a rate limit.

Get-MgDirectoryDeletedItem -DirectoryObjectId microsoft.graph.user -Property '*'

Above Mg Graph command let returning only 100(max) values. However, i have around 1000 values in the deleted list. Also, it do not take "-All", "Page Size" etc properties.

Any guidance on how can i get the list all deleted users via PowerShell?


Solution

  • Mg Graph command let returning only 100(max) values. However, i have around 1000 values in the deleted list. Also, it do not take "-All", "Page Size" etc properties.

    Here is the command to get more than 100 Azure AD deleted users.

    Powershell Comamnd:

    Install-Module Microsoft.Graph.Identity.DirectoryManagement
    Get-MgDirectoryDeletedItemAsUser -PageSize 114 | Export-Csv -Path "C:\ZipFolder\AzureADuserdel-27-2023.csv"
    

    MS Graph Result:

    enter image description here

    Note: PageSize 114 define the number as per your requirement.

    enter image description here

    Once the above command is run, it will fetch deleted Azure AD users and export them to an excel file as below.

    Output:

    enter image description here

    Reference: Retrieve the count of deleted user