你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzADAppCredential
为应用程序创建密钥凭据或密码凭据。
语法
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>]
说明
为应用程序创建密钥凭据或密码凭据。
示例
示例 1:为应用程序创建密钥凭据
# 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
使用对象 ID 为应用程序创建密钥凭据$Id
示例 2:为应用程序创建密码凭据
# 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
为应用程序创建密码凭据
参数
-ApplicationId
应用程序 ID。
类型: | Guid |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ApplicationObject
应用程序对象可用作管道输入。
类型: | IMicrosoftGraphApplication |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-CertValue
“非对称”凭据类型的值。 它表示 base 64 编码的证书。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-CustomKeyIdentifier
自定义密钥标识符。
格式应为 base64:$Bytes=[System.Text.Encoding]::Unicode.GetBytes($key);$key=[Convert]::ToBase64String($Bytes)
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | PSObject |
别名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DisplayName
应用程序的显示名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-EndDate
凭据使用情况的有效结束日期。 默认结束日期值为从今天开始的一年。 对于“非对称”类型凭据,必须将其设置为 X509 证书有效日期或之前。
类型: | DateTime |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-KeyCredentials
与应用程序关联的密钥凭据。
类型: | MicrosoftGraphKeyCredential[] |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ObjectId
应用程序的对象 ID。
类型: | String |
别名: | Id |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-PasswordCredentials
与应用程序关联的密码凭据。
类型: | MicrosoftGraphPasswordCredential[] |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-StartDate
凭据使用情况的有效开始日期。 默认开始日期值为今天。 对于“非对称”类型凭据,必须设置为 X509 证书有效日期或之后的日期。
类型: | DateTime |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |