New-EntraServicePrincipalPasswordCredential
Creates a password credential for a service principal.
Syntax
Default (Default)
New-EntraServicePrincipalPasswordCredential
-ServicePrincipalId <String>
[-EndDate <DateTime>]
[-StartDate <DateTime>]
[-DisplayName <String>]
[<CommonParameters>]
Description
The New-EntraServicePrincipalPasswordCredential cmdlet creates a password credential for a service principal in Microsoft Entra ID.
Examples
Example 1: Create a password credential with StartDate
Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
New-EntraServicePrincipalPasswordCredential -ServicePrincipalId $servicePrincipal.Id -DisplayName 'Helpdesk App Credential' -StartDate '2024-11-04T14:14:14Z'
secretText : A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u
@odata.type : #microsoft.graph.servicePrincipal
endDateTime : 08-08-2026 10:30:00
hint : LY.
customKeyIdentifier :
startDateTime : 08-08-2024 14:14:14
keyId : aaaaaaaa-0b0b-1c1c-2d2d-333333333333
@odata.context : https://graph.microsoft.com/beta/$metadata#servicePrincipals('00001111-aaaa-2222-bbbb-3333cccc4444')/addPassword
displayName :
StartDate : 08-08-2024 14:14:14
EndDate : 08-08-2026 10:30:00
This example demonstrates how to create a password credential with StartDate for a service principal in Microsoft Entra ID.
-ServicePrincipalIdparameter specifies the ID of a service principal.-DisplayNameparameter specifies a friendly name for the password.-StarteDateparameter specifies the date and time at which the password becomes valid.
Example 2: Create a password credential with EndDate
Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
New-EntraServicePrincipalPasswordCredential -ServicePrincipalId $servicePrincipal.Id -DisplayName 'Helpdesk App Credential' -EndDate '2024-11-04T14:14:14Z'
secretText : A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u
@odata.type : #microsoft.graph.servicePrincipal
endDateTime : 08-08-2026 10:30:00
hint : LY.
customKeyIdentifier :
startDateTime : 08-08-2024 14:14:14
keyId : bbbbbbbb-1c1c-2d2d-3e3e-444444444444
@odata.context : https://graph.microsoft.com/beta/$metadata#servicePrincipals('00001111-aaaa-2222-bbbb-3333cccc4444')/addPassword
displayName :
StartDate : 08-08-2024 14:14:14
EndDate : 08-08-2026 10:30:00
This example demonstrates how to create a password credential with EndDate for a service principal in Microsoft Entra ID.
-ServicePrincipalIdparameter specifies the ID of a service principal.-DisplayNameparameter specifies a friendly name for the password.-EndDateparameter specifies the date and time at which the password expires represented using ISO 8601 format and is always in UTC time.
Parameters
-DisplayName
The friendly name for the password.
Parameter properties
| Type: | System.String |
| 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 |
-EndDate
The date and time at which the password expires represented using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2024 is 2024-01-01T00:00:00Z.
Parameter properties
| Type: | System.DateTime |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | True |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-ServicePrincipalId
Specifies the ID of the service principal.
Parameter properties
| Type: | System.String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ObjectId |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | True |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-StartDate
The date and time at which the password becomes valid. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2024 is 2024-01-01T00:00:00Z.
Parameter properties
| Type: | System.DateTime |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | True |
| Value from pipeline by property name: | True |
| 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.