Get-AzADSpCredential
Retrieves a list of credentials associated with a service principal.
Warning
There are upcoming breaking changes in this cmdlet. These changes are currently in preview with Az.Resources version 5.0.0-preview. They will become generally available with our next major release of the Az PowerShell module, version 7.x in December of 2021. For more information, see Azure AD to Microsoft Graph migration changes in Azure PowerShell.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
Get-AzADSpCredential
-ObjectId <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzADSpCredential
-ServicePrincipalName <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzADSpCredential
-DisplayName <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzADSpCredential
-ServicePrincipalObject <PSADServicePrincipal>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Get-AzADSpCredential cmdlet can be used to retrieve a list of credentials associated with a service principal. This command will retrieve all of the credential properties (but not the credential value) associated with the service principal.
Examples
Example 1: List credentials by SPN
PS C:\> Get-AzADSpCredential -ServicePrincipalName http://test12345
Returns a list of credentials associated with the service principal with SPN 'http://test12345'.
Example 2: List credentials by object id
PS C:\> Get-AzADSpCredential -ObjectId 58e28616-99cc-4da4-b705-7672130e1047
Returns a list of credentials associated with the service principal with object id "58e28616-99cc-4da4-b705-7672130e1047".
Example 3: List credentials by piping
PS C:\> Get-AzADServicePrincipal -ObjectId 58e28616-99cc-4da4-b705-7672130e1047 | Get-AzADSpCredential
Gets the service principal with object id "58e28616-99cc-4da4-b705-7672130e1047" and pipes it to the Get-AzADSpCredential cmdlet to list all credentials for that service principal.
Parameters
The credentials, account, tenant, and subscription used for communication with azure
| Type: | IAzureContextContainer |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The display name of the service principal
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
The object id of the service principal to retrieve credentials from.
| Type: | String |
| Aliases: | Id |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
The name (SPN) of the service principal to retrieve credentials from.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
The service principal object to retrieve the credentials from.
| Type: | PSADServicePrincipal |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |