Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-AzADSpCredential
- Module:
- Az.Resources Module
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
-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
-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
-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
-KeyCredentials
key credentials associated with the service principal.
Parameter properties
| Type: | |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ObjectId
The object Id of application.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Id, ServicePrincipalObjectId |
Parameter sets
-PasswordCredentials
Password credentials associated with the service principal.
Parameter properties
| Type: | |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ServicePrincipalName
The service principal name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | SPN |
Parameter sets
-ServicePrincipalObject
The service principal object, could be used as pipeline input.
Parameter properties
| Type: | IMicrosoftGraphServicePrincipal |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-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
-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
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.
Inputs
IMicrosoftGraphServicePrincipal
Outputs
IMicrosoftGraphKeyCredential
IMicrosoftGraphPasswordCredential
Notes
ALIASES
New-AzADServicePrincipalCredential
Azure PowerShell
Feedback
Was this page helpful?
