Edit

Remove-AzADServicePrincipal

Deletes the Microsoft Entra service principal.

Syntax

ObjectIdParameterSet (Default)

Remove-AzADServicePrincipal
    -ObjectId <Guid>
    [-PassThru]
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationIdParameterSet

Remove-AzADServicePrincipal
    -ApplicationId <Guid>
    [-PassThru]
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

SPNParameterSet

Remove-AzADServicePrincipal
    -ServicePrincipalName <String>
    [-PassThru]
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DisplayNameParameterSet

Remove-AzADServicePrincipal
    -DisplayName <String>
    [-PassThru]
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

InputObjectParameterSet

Remove-AzADServicePrincipal
    -InputObject <PSADServicePrincipal>
    [-PassThru]
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectParameterSet

Remove-AzADServicePrincipal
    -ApplicationObject <PSADApplication>
    [-PassThru]
    [-Force]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Deletes the Microsoft Entra service principal.

Examples

Example 1 - Remove a service principal by object id

PS C:\> Remove-AzADServicePrincipal -ObjectId aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb

Removes the service principal with object id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb'.

Example 2 - Remove a service principal by application id

PS C:\> Remove-AzADServicePrincipal -ApplicationId 00001111-aaaa-2222-bbbb-3333cccc4444

Removes the service principal with application id '00001111-aaaa-2222-bbbb-3333cccc4444'.

Example 3 - Remove a service principal by SPN

PS C:\> Remove-AzADServicePrincipal -ServicePrincipalName MyServicePrincipal

Remove the service principal with service principal name "MyServicePrincipal"

Example 4 - Remove a service principal by piping

PS C:\> Get-AzADServicePrincipal -ObjectId aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb | Remove-AzADServicePrincipal

Gets the service principal with object id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' and pipes that to the Remove-AzADServicePrincipal cmdlet to remove that service principal.

Example 5 - Remove a service principal by piping an application

PS C:\> Get-AzApplication -ApplicationId 00001111-aaaa-2222-bbbb-3333cccc4444 | Remove-AzADServicePrincipal

Gets the application with application id '00001111-aaaa-2222-bbbb-3333cccc4444' and pipes that to the Remove-AzADServicePrincipal cmdlet to remove the service principal associated with that application.

Parameters

-ApplicationId

The service principal application id.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ApplicationIdParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ApplicationObject

The application object whose service principal is being removed.

Parameter properties

Type:PSADApplication
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ApplicationObjectParameterSet
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DisplayName

The display name of the service principal.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

DisplayNameParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Force

Switch to delete service principal without a confirmation.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

The service principal object.

Parameter properties

Type:PSADServicePrincipal
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

InputObjectParameterSet
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-ObjectId

The object id of the service principal to delete.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False
Aliases:PrincipalId, Id

Parameter sets

ObjectIdParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PassThru

If specified, returns the deleted service principal.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ServicePrincipalName

The service principal name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:SPN

Parameter sets

SPNParameterSet
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Guid

String

PSADServicePrincipal

Parameters: InputObject (ByValue)

PSADApplication

Parameters: ApplicationObject (ByValue)

Outputs

PSADServicePrincipal

Notes

Keywords: azure, Az, arm, resource, management, manager, resource, group, template, deployment