New-AzADSpCredential
Creates key credentials or password credentials for an service principal.
Syntax
SpObjectIdWithPasswordParameterSet (Default)
New-AzADSpCredential
-ObjectId <String>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SpObjectIdWithCertValueParameterSet
New-AzADSpCredential
-ObjectId <String>
-CertValue <String>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SpObjectIdWithKeyCredentialParameterSet
New-AzADSpCredential
-ObjectId <String>
-KeyCredentials <MicrosoftGraphKeyCredential[]>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SpObjectIdWithPasswordCredentialParameterSet
New-AzADSpCredential
-ObjectId <String>
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ServicePrincipalObjectWithCertValueParameterSet
New-AzADSpCredential
-CertValue <String>
-ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ServicePrincipalObjectWithPasswordParameterSet
New-AzADSpCredential
-ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SPNWithCertValueParameterSet
New-AzADSpCredential
-CertValue <String>
-ServicePrincipalName <String>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SPNWithPasswordParameterSet
New-AzADSpCredential
-ServicePrincipalName <String>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ServicePrincipalObjectWithPasswordCredentialParameterSet
New-AzADSpCredential
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
-ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SPNWithPasswordCredentialParameterSet
New-AzADSpCredential
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
-ServicePrincipalName <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ServicePrincipalObjectWithKeyCredentialParameterSet
New-AzADSpCredential
-KeyCredentials <MicrosoftGraphKeyCredential[]>
-ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SPNWithKeyCredentialParameterSet
New-AzADSpCredential
-KeyCredentials <MicrosoftGraphKeyCredential[]>
-ServicePrincipalName <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Creates key credentials or password credentials for an service principal.
Examples
Example 1: Create key credentials for service principal
$credential = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphKeyCredential" `
-Property @{'Key' = $cert;
'Usage' = 'Verify';
'Type' = 'AsymmetricX509Cert'
}
New-AzADSpCredential -ObjectId $Id -KeyCredentials $credential
Create key credentials for service principal
Example 2: Create password credentials for service principal
Get-AzADServicePrincipal -ApplicationId $appId | New-AzADSpCredential -StartDate $startDate -EndDate $endDate
Create password credentials for service principal
Parameters
-CertValue
The value of the 'asymmetric' credential type.
It represents the base 64 encoded certificate.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SpObjectIdWithCertValueParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithCertValueParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithCertValueParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: PSObject
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
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 effective end date of the credential usage.
The default end date value is one year from today.
For an 'asymmetric' type credential, this must be set to on or before the date that the X509 certificate is valid.
Parameter properties
Type: DateTime
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SpObjectIdWithPasswordParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SpObjectIdWithCertValueParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithCertValueParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithPasswordParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithCertValueParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithPasswordParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-KeyCredentials
key credentials associated with the service principal.
Parameter properties
Parameter sets
SpObjectIdWithKeyCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithKeyCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithKeyCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ObjectId
The object Id of application.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Id, ServicePrincipalObjectId
Parameter sets
SpObjectIdWithPasswordParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SpObjectIdWithCertValueParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SpObjectIdWithKeyCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SpObjectIdWithPasswordCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-PasswordCredentials
Password credentials associated with the service principal.
Parameter properties
Parameter sets
SpObjectIdWithPasswordCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithPasswordCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithPasswordCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ServicePrincipalName
The service principal name.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: SPN
Parameter sets
SPNWithCertValueParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithPasswordParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithPasswordCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithKeyCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ServicePrincipalObject
The service principal object, could be used as pipeline input.
Parameter properties
Parameter sets
ServicePrincipalObjectWithCertValueParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithPasswordParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithPasswordCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithKeyCredentialParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-StartDate
The effective start date of the credential usage.
The default start date value is today.
For an 'asymmetric' type credential, this must be set to on or after the date that the X509 certificate is valid from.
Parameter properties
Type: DateTime
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
SpObjectIdWithPasswordParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SpObjectIdWithCertValueParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithCertValueParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
ServicePrincipalObjectWithPasswordParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithCertValueParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
SPNWithPasswordParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
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 .
Outputs
Notes
ALIASES
New-AzADServicePrincipalCredential