Bearbeiten

Freigeben über


New-AzADSpCredential

Creates key credentials or password credentials for an service principal.

Syntax

New-AzADSpCredential
   -ObjectId <String>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   -ObjectId <String>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   -CertValue <String>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   -ObjectId <String>
   -KeyCredentials <MicrosoftGraphKeyCredential[]>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   -ObjectId <String>
   -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   -CertValue <String>
   -ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   -ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   -CertValue <String>
   -ServicePrincipalName <String>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   -ServicePrincipalName <String>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
   -ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
   -ServicePrincipalName <String>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzADSpCredential
   -KeyCredentials <MicrosoftGraphKeyCredential[]>
   -ServicePrincipalObject <IMicrosoftGraphServicePrincipal>
   [-DefaultProfile <PSObject>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
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.

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:PSObject
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyCredentials

key credentials associated with the service principal.

Type:MicrosoftGraphKeyCredential[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ObjectId

The object Id of application.

Type:String
Aliases:Id, ServicePrincipalObjectId
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-PasswordCredentials

Password credentials associated with the service principal.

Type:MicrosoftGraphPasswordCredential[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ServicePrincipalName

The service principal name.

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

-ServicePrincipalObject

The service principal object, could be used as pipeline input.

Type:IMicrosoftGraphServicePrincipal
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

IMicrosoftGraphServicePrincipal

Outputs

IMicrosoftGraphKeyCredential

IMicrosoftGraphPasswordCredential

Notes

ALIASES

New-AzADServicePrincipalCredential