Get-EntraDeletedServicePrincipal
Retrieves the list of previously deleted service principals.
Syntax
Get-EntraDeletedServicePrincipal
[-Filter <String>]
[-All]
[-Top <Int32>]
[-Property <String[]>]
[<CommonParameters>]
Get-EntraDeletedServicePrincipal
[-SearchString <String>]
[-All]
[-Property <String[]>]
[<CommonParameters>]
Get-EntraDeletedServicePrincipal
-ServicePrincipalId <String>
[-All]
[-Property <String[]>]
[<CommonParameters>]
Description
The Get-EntraDeletedServicePrincipal
cmdlet Retrieves the list of previously deleted service principals.
Examples
Example 1: Get list of deleted service principals
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraDeletedServicePrincipal | Select-Object Id, DisplayName, AppId, DeletedDateTime, DeletionAgeInDays, ServicePrincipalType | Format-Table -AutoSize
Id DisplayName AppId DeletedDateTime DeletionAgeInDays ServicePrincipalType
-- ----------- ----- --------------- ----------------- --------------------
bbbbbbbb-1111-2222-3333-cccccccccccc Contoso Marketing 00001111-aaaa-2222-bbbb-3333cccc4444 2/10/2025 11:07:07 AM 10 Application
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb ProjectWorkManagement 22223333-cccc-4444-dddd-5555eeee6666 2/12/2025 11:07:56 AM 8 ManagedIdentity
dddddddd-3333-4444-5555-eeeeeeeeeeee Enterprise App1 33334444-dddd-5555-eeee-6666ffff7777 2/11/2025 11:07:56 AM 11 ManagedIdentity
This cmdlet retrieves the list of deleted service principals.
Example 2: Get list of deleted service principals using All parameter
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraDeletedServicePrincipal -All | Select-Object Id, DisplayName, AppId, DeletedDateTime, DeletionAgeInDays, ServicePrincipalType | Format-Table -AutoSize
Id DisplayName AppId DeletedDateTime DeletionAgeInDays ServicePrincipalType
-- ----------- ----- --------------- ----------------- --------------------
bbbbbbbb-1111-2222-3333-cccccccccccc Contoso Marketing 00001111-aaaa-2222-bbbb-3333cccc4444 2/10/2025 11:07:07 AM 10 Application
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb ProjectWorkManagement 22223333-cccc-4444-dddd-5555eeee6666 2/12/2025 11:07:56 AM 8 ManagedIdentity
dddddddd-3333-4444-5555-eeeeeeeeeeee Enterprise App1 33334444-dddd-5555-eeee-6666ffff7777 2/11/2025 11:07:56 AM 11 ManagedIdentity
This cmdlet retrieves the list of deleted service principals using All parameter.
Example 3: Get top two deleted service principals
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraDeletedServicePrincipal -Top 2 | Select-Object Id, DisplayName, AppId, DeletedDateTime, DeletionAgeInDays, ServicePrincipalType | Format-Table -AutoSize
Id DisplayName AppId DeletedDateTime DeletionAgeInDays ServicePrincipalType
-- ----------- ----- --------------- ----------------- --------------------
bbbbbbbb-1111-2222-3333-cccccccccccc Contoso Marketing 00001111-aaaa-2222-bbbb-3333cccc4444 2/10/2025 11:07:07 AM 10 Application
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb ProjectWorkManagement 22223333-cccc-4444-dddd-5555eeee6666 2/12/2025 11:07:56 AM 8 ManagedIdentity
This cmdlet retrieves top two deleted service principals. You can use -Limit
as an alias for -Top
.
Example 4: Get deleted service principals using SearchString parameter
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraDeletedServicePrincipal -SearchString 'Contoso Marketing' | Select-Object Id, DisplayName, AppId, DeletedDateTime, DeletionAgeInDays, ServicePrincipalType | Format-Table -AutoSize
Id DisplayName AppId DeletedDateTime DeletionAgeInDays ServicePrincipalType
-- ----------- ----- --------------- ----------------- --------------------
bbbbbbbb-1111-2222-3333-cccccccccccc Contoso Marketing 00001111-aaaa-2222-bbbb-3333cccc4444 2/10/2025 11:07:07 AM 10 Application
This cmdlet retrieves deleted service principals using SearchString parameter.
Example 5: Get deleted service principals filter by display name
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraDeletedServicePrincipal -Filter "DisplayName eq 'Contoso Marketing'" | Select-Object Id, DisplayName, AppId, DeletedDateTime, DeletionAgeInDays, ServicePrincipalType | Format-Table -AutoSize
Id DisplayName AppId DeletedDateTime DeletionAgeInDays ServicePrincipalType
-- ----------- ----- --------------- ----------------- --------------------
bbbbbbbb-1111-2222-3333-cccccccccccc Contoso Marketing 00001111-aaaa-2222-bbbb-3333cccc4444 2/10/2025 11:07:07 AM 10 Application
This cmdlet retrieves deleted service principals having specified display name.
Example 6: Get deleted service principal by ServicePrincipalId
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraDeletedServicePrincipal -ServicePrincipalId 'bbbbbbbb-1111-2222-3333-cccccccccccc' | Select-Object Id, DisplayName, AppId, DeletedDateTime, DeletionAgeInDays, ServicePrincipalType | Format-Table -AutoSize
Id DisplayName AppId DeletedDateTime DeletionAgeInDays ServicePrincipalType
-- ----------- ----- --------------- ----------------- --------------------
bbbbbbbb-1111-2222-3333-cccccccccccc Contoso Marketing 00001111-aaaa-2222-bbbb-3333cccc4444 2/10/2025 11:07:07 AM 10 Application
This cmdlet retrieves the deleted service principal specified by ServicePrincipalId.
-ServicePrincipalId
parameter specifies the deleted service principal Id.
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
Retrieve only those deleted service principals that satisfy the filter.
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
Retrieve only those service principals that satisfy the -SearchString value.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServicePrincipalId
The unique ID of the deleted service principal to be retrieved.
Type: | System.String |
Aliases: | Id |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Top
The maximum number of service principals.
Type: | System.Int32 |
Aliases: | Limit |
Position: | Named |
Default value: | None |
Required: | False |
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