Get-EntraDeletedUser
Retrieves soft-deleted (recently deleted) users in Microsoft Entra ID.
Syntax
Get-EntraDeletedUser
[-Top <Int32>]
[-All]
[-Filter <String>]
[-Property <String[]>]
[<CommonParameters>]
Get-EntraDeletedUser
[-All]
[-SearchString <String>]
[-Property <String[]>]
[<CommonParameters>]
Get-EntraDeletedUser
-UserId <String>
[-All]
[-Property <String[]>]
[<CommonParameters>]
Description
The Get-EntraDeletedUser
cmdlet retrieves soft-deleted (recently deleted) users from the directory. Deleted users can be recovered within 30 days, after which they're permanently deleted.
Examples
Example 1: Get deleted users in the directory
Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser
Id DisplayName UserPrincipalName UserType DeletedDateTime PermanentDeletionDate
-- ----------- ----------------- -------- --------------- ---------------------
cccccccc-2222-3333-4444-dddddddddddd Angel Brown cccccccc222233334444ddddddddddddAngelB@contoso.com
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith dddddddd333344445555eeeeeeeeeeeeAveryS@contoso.com
eeeeeeee-4444-5555-6666-ffffffffffff Sawyer Miller eeeeeeee444455556666ffffffffffffSawyerM@contoso.com
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Alain Davignon aaaaaaaa000011112222bbbbbbbbbbbbAlainD@contoso.com
This example shows how to retrieve all recoverable deleted users in the Microsoft Entra ID.
Example 2: Get deleted users in the directory using All parameter
Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -All
Id DisplayName UserPrincipalName UserType DeletedDateTime PermanentDeletionDate
-- ----------- ----------------- -------- --------------- ---------------------
cccccccc-2222-3333-4444-dddddddddddd Angel Brown cccccccc222233334444ddddddddddddAngelB@contoso.com
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith dddddddd333344445555eeeeeeeeeeeeAveryS@contoso.com
eeeeeeee-4444-5555-6666-ffffffffffff Sawyer Miller eeeeeeee444455556666ffffffffffffSawyerM@contoso.com
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Alain Davignon aaaaaaaa000011112222bbbbbbbbbbbbAlainD@contoso.com
This example shows how to retrieve all recoverable deleted users, using All parameter.
Example 3: Get top two deleted users
Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -Top 2 #alias: Limit e.g. -Limit 2
Id DisplayName UserPrincipalName UserType DeletedDateTime PermanentDeletionDate
-- ----------- ----------------- -------- --------------- ---------------------
cccccccc-2222-3333-4444-dddddddddddd Angel Brown cccccccc222233334444ddddddddddddAngelB@contoso.com
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith dddddddd333344445555eeeeeeeeeeeeAveryS@contoso.com
This example shows how to retrieve the top two recoverable deleted users in the directory. You can also use the alias Limit
.
Example 4: Get deleted users containing string 'Avery Smith'
Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -SearchString 'Avery Smith'
Id DisplayName UserPrincipalName UserType DeletedDateTime PermanentDeletionDate
-- ----------- ----------------- -------- --------------- ---------------------
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith dddddddd333344445555eeeeeeeeeeeeAveryS@contoso.com
This example shows how to retrieve deleted users in the directory, containing the specified string.
Example 5: Get deleted users filter by display name
Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -Filter "displayName eq 'Avery Smith'"
Id DisplayName UserPrincipalName UserType DeletedDateTime PermanentDeletionDate
-- ----------- ----------------- -------- --------------- ---------------------
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith dddddddd333344445555eeeeeeeeeeeeAveryS@contoso.com
This example shows how to retrieve deleted users in the directory, having the specified display name.
Example 6: Get deleted user by UserId
Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -UserId 'dddddddd-3333-4444-5555-eeeeeeeeeeee'
Id DisplayName UserPrincipalName UserType DeletedDateTime PermanentDeletionDate
-- ----------- ----------------- -------- --------------- ---------------------
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith dddddddd333344445555eeeeeeeeeeeeAveryS@contoso.com
This example shows how to retrieve the deleted user specified by UserId.
-UserId
parameter specifies the deleted user UserId.
Parameters
-All
List all pages.
Type: | System.Management.Automation.SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Filter
Specifies an OData v4.0 filter statement. This parameter controls which objects are returned.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Property
Specifies properties to be returned
Type: | System.String[] |
Aliases: | Select |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SearchString
Specifies a search string.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Top
Specifies the maximum number of records to return.
Type: | System.Int32 |
Aliases: | Limit |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-UserId
The ObjectId or User Principal Name of the deleted user to be retrieved.
Type: | System.String |
Aliases: | Id |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
System.String
System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
Outputs
System.Object