你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzADAppCredential
Creates key credentials or password credentials for an application.
Syntax
New-AzADAppCredential
-ObjectId <String>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
-ObjectId <String>
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-CertValue <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
-ObjectId <String>
[-CustomKeyIdentifier <String>]
-KeyCredentials <MicrosoftGraphKeyCredential[]>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
-ObjectId <String>
[-CustomKeyIdentifier <String>]
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-ApplicationObject <IMicrosoftGraphApplication>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-CertValue <String>
-ApplicationObject <IMicrosoftGraphApplication>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-DisplayName <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-CertValue <String>
-DisplayName <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-CertValue <String>
-ApplicationId <Guid>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[-CustomKeyIdentifier <String>]
-ApplicationId <Guid>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-CustomKeyIdentifier <String>]
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
-ApplicationObject <IMicrosoftGraphApplication>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-CustomKeyIdentifier <String>]
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
-DisplayName <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-CustomKeyIdentifier <String>]
-PasswordCredentials <MicrosoftGraphPasswordCredential[]>
-ApplicationId <Guid>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-CustomKeyIdentifier <String>]
-KeyCredentials <MicrosoftGraphKeyCredential[]>
-ApplicationObject <IMicrosoftGraphApplication>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-CustomKeyIdentifier <String>]
-KeyCredentials <MicrosoftGraphKeyCredential[]>
-DisplayName <String>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzADAppCredential
[-CustomKeyIdentifier <String>]
-KeyCredentials <MicrosoftGraphKeyCredential[]>
-ApplicationId <Guid>
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Creates key credentials or password credentials for an application.
Examples
Example 1: Create key credentials for application
# ObjectId is the string representation of a GUID for directory object, application, in Azure AD.
$Id = "00000000-0000-0000-0000-000000000000"
# $cert is Base64 encoded content of certificate
$credential = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphKeyCredential" `
-Property @{'Key' = $cert;
'Usage' = 'Verify';
'Type' = 'AsymmetricX509Cert'
}
New-AzADAppCredential -ObjectId $Id -KeyCredentials $credential
Create key credentials for application with object Id $Id
Example 2: Create password credentials for application
# ApplicationId is AppId of Application object which is different from directory id in Azure AD.
Get-AzADApplication -ApplicationId $appId | New-AzADAppCredential -StartDate $startDate -EndDate $endDate
Create password credentials for application
Parameters
-ApplicationId
The application Id.
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ApplicationObject
The application object, could be used as pipeline input.
Type: | IMicrosoftGraphApplication |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-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 |
-CustomKeyIdentifier
Custom Key Identifier.
The format should be base64: $Bytes=[System.Text.Encoding]::Unicode.GetBytes($key);$key=[Convert]::ToBase64String($Bytes)
Type: | String |
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 |
-DisplayName
The display name of application.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
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 application.
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 |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PasswordCredentials
Password credentials associated with the application.
Type: | MicrosoftGraphPasswordCredential[] |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
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 |