Get-EntraServicePrincipalKeyCredential

Get key credentials for a service principal.

Syntax

Get-EntraServicePrincipalKeyCredential
   -ServicePrincipalId <String>
   [<CommonParameters>]

Description

The Get-EntraServicePrincipalKeyCredential cmdlet gets the key credentials for a service principal in Microsoft Entra ID.

Examples

Example 1: Retrieve the key credential of a service principal

Connect-Entra -Scopes 'Application.Read.All'
$ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq '<service-principal-display-name>'"
Get-EntraServicePrincipalKeyCredential -ServicePrincipalId $ServicePrincipal.ObjectId

CustomKeyIdentifier DisplayName EndDateTime         Key KeyId                                StartDateTime       Type      Usage
------------------- ----------- -----------         --- -----                                -------------       ----      -----
                                08-02-2025 09:57:08     68b45e27-fef8-4f0d-bc7a-76bd949c16d1 08-02-2024 09:57:08 Symmetric Sign

This example retrieves the key credentials for specified service principal in Microsoft Entra ID. You can use the command Get-EntraServicePrincipal to get a service principal object Id.

  • -ServicePrincipalId parameter specifies the service principal Id.

Parameters

-ServicePrincipalId

Specifies the ID of the application for which to get the password credential.

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