Remove-AzureRmADServicePrincipal

Deletes the Microsoft Entra service principal.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

Remove-AzureRmADServicePrincipal
      -ObjectId <Guid>
      [-PassThru]
      [-Force]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzureRmADServicePrincipal
      -ApplicationId <Guid>
      [-PassThru]
      [-Force]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzureRmADServicePrincipal
      -ServicePrincipalName <String>
      [-PassThru]
      [-Force]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzureRmADServicePrincipal
      -DisplayName <String>
      [-PassThru]
      [-Force]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzureRmADServicePrincipal
      -InputObject <PSADServicePrincipal>
      [-PassThru]
      [-Force]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzureRmADServicePrincipal
      -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-AzureRmADServicePrincipal -ObjectId 61b5d8ea-fdc6-40a2-8d5b-ad447c678d45

Removes the service principal with object id '61b5d8ea-fdc6-40a2-8d5b-ad447c678d45'.

Example 2 - Remove a service principal by application id

PS C:\> Remove-AzureRmADServicePrincipal -ApplicationId 9263469e-d328-4321-8646-3e3e75d20e76

Removes the service principal with application id '9263469e-d328-4321-8646-3e3e75d20e76'.

Example 3 - Remove a service principal by SPN

PS C:\> Remove-AzureRmADServicePrincipal -ServicePrincipalName MyServicePrincipal

Remove the service principal with service principal name "MyServicePrincipal"

Example 4 - Remove a service principal by piping

PS C:\> Get-AzureRmADServicePrincipal -ObjectId 61b5d8ea-fdc6-40a2-8d5b-ad447c678d45 | Remove-AzureRmADServicePrincipal

Gets the service principal with object id '61b5d8ea-fdc6-40a2-8d5b-ad447c678d45' and pipes that to the Remove-AzureRmADServicePrincipal cmdlet to remove that service principal.

Example 5 - Remove a service principal by piping an application

PS C:\> Get-AzureRmApplication -ApplicationId 9263469e-d328-4321-8646-3e3e75d20e76 | Remove-AzureRmADServicePrincipal

Gets the application with application id '9263469e-d328-4321-8646-3e3e75d20e76' and pipes that to the Remove-AzureRmADServicePrincipal cmdlet to remove the service principal associated with that application.

Parameters

-ApplicationId

The service principal application id.

Type:Guid
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ApplicationObject

The application object whose service principal is being removed.

Type:PSADApplication
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DisplayName

The display name of the service principal.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Force

Switch to delete service principal without a confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

The service principal object.

Type:PSADServicePrincipal
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ObjectId

The object id of the service principal to delete.

Type:Guid
Aliases:PrincipalId, Id
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

If specified, returns the deleted service principal.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ServicePrincipalName

The service principal name.

Type:String
Aliases:SPN
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Guid

String

PSADServicePrincipal

Parameters: InputObject (ByValue)

PSADApplication

Parameters: ApplicationObject (ByValue)

Outputs

PSADServicePrincipal

Notes

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