The Remove-MsolServicePrincipalCredential cmdlet in PowerShell removes a credential key from a service principal in Microsoft Office 365.
The syntax to delete a credential key from a service principal is given below.
Remove-MsolServicePrincipalCredential -ObjectId <Guid> -KeyIds <Guid> -ServicePrincipalName <String> -AppPrincipalId <Guid> [-TenantId <Guid>] [<CommonParameters>]
In this article, we will discuss how to use the Remove-MsolServicePrincipalCredential cmdlet in PowerShell to remove a credential from a service principal in Azure Active Directory.
How to Remove a Credential from a Service Principal
To remove a credential from a service principal in Office 365, use the Remove-MsolServicePrincipalCredential with
-KeyIds parameter specifies an array of unique IDs of credential keys to remove. You can get the key ID of a service principal using the Get-MsolServicePrincipalCredential cmdlet.
-ServicePrincipalName parameter specifies the name of the service principal from which to remove the credentials. An SPN must use one of the following formats:
- a valid URL
# Remove the credentials for a service principal Remove-MsolServicePrincipalCredential -KeyIds @("8a569c80-a495-40b0-bc2a-b72e38e1688e") -ServicePrincipalName "ShellGeek/ShellApp.com"
This command removes a credential key from a service principal. In the above example, the key ID retrieved using the Get-MsolServicePrincipalCredential cmdlet “8a569c80-a495-40b0-bc2a-b72e38e1688e” is removed from the service principal associated with the service principal name “ShellGeek/ShellApp.com“.
I hope the above article on how to remove a credential from a service principal using the Remove-MsolServicePrincipalCredential cmdlet in PowerShell is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.