你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzADAppCredential

为应用程序创建密钥凭据或密码凭据。

语法

ApplicationObjectIdWithPasswordParameterSet (默认值)

New-AzADAppCredential
    -ObjectId <String>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectIdWithCertValueParameterSet

New-AzADAppCredential
    -ObjectId <String>
    -CertValue <String>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectIdWithKeyCredentialParameterSet

New-AzADAppCredential
    -ObjectId <String>
    -KeyCredentials <MicrosoftGraphKeyCredential[]>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectIdWithPasswordCredentialParameterSet

New-AzADAppCredential
    -ObjectId <String>
    -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectWithPasswordParameterSet

New-AzADAppCredential
    -ApplicationObject <IMicrosoftGraphApplication>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectWithCertValueParameterSet

New-AzADAppCredential
    -CertValue <String>
    -ApplicationObject <IMicrosoftGraphApplication>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DisplayNameWithPasswordParameterSet

New-AzADAppCredential
    -DisplayName <String>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DisplayNameWithCertValueParameterSet

New-AzADAppCredential
    -CertValue <String>
    -DisplayName <String>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationIdWithCertValueParameterSet

New-AzADAppCredential
    -CertValue <String>
    -ApplicationId <Guid>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationIdWithPasswordParameterSet

New-AzADAppCredential
    -ApplicationId <Guid>
    [-StartDate <DateTime>]
    [-EndDate <DateTime>]
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectWithPasswordCredentialParameterSet

New-AzADAppCredential
    -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
    -ApplicationObject <IMicrosoftGraphApplication>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DisplayNameWithPasswordCredentialParameterSet

New-AzADAppCredential
    -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
    -DisplayName <String>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationIdWithPasswordCredentialParameterSet

New-AzADAppCredential
    -PasswordCredentials <MicrosoftGraphPasswordCredential[]>
    -ApplicationId <Guid>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationObjectWithKeyCredentialParameterSet

New-AzADAppCredential
    -KeyCredentials <MicrosoftGraphKeyCredential[]>
    -ApplicationObject <IMicrosoftGraphApplication>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DisplayNameWithKeyCredentialParameterSet

New-AzADAppCredential
    -KeyCredentials <MicrosoftGraphKeyCredential[]>
    -DisplayName <String>
    [-CustomKeyIdentifier <String>]
    [-DefaultProfile <PSObject>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ApplicationIdWithKeyCredentialParameterSet

New-AzADAppCredential
    -KeyCredentials <MicrosoftGraphKeyCredential[]>
    -ApplicationId <Guid>
    [-CustomKeyIdentifier <String>]
    [-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
默认值:None
支持通配符:False
不显示:False

参数集

ApplicationIdWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithPasswordParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ApplicationObject

应用程序对象可用作管道输入。

参数属性

类型:IMicrosoftGraphApplication
默认值:None
支持通配符:False
不显示:False

参数集

ApplicationObjectWithPasswordParameterSet
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-CertValue

“非对称”凭据类型的值。 它表示 base 64 编码的证书。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ApplicationObjectIdWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

在运行 cmdlet 之前,提示你进行确认。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-CustomKeyIdentifier

自定义密钥标识符。 格式应为 base64: $Bytes=[System.Text.Encoding]::Unicode.GetBytes($key);$key=[Convert]::ToBase64String($Bytes)

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

参数属性

类型:PSObject
默认值:None
支持通配符:False
不显示:False
别名:AzContext, AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DisplayName

应用程序的显示名称。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

DisplayNameWithPasswordParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-EndDate

凭据使用情况的有效结束日期。 默认结束日期值为从今天开始的一年。 对于“非对称”类型凭据,必须将其设置为 X509 证书有效日期或之前。

参数属性

类型:DateTime
默认值:None
支持通配符:False
不显示:False

参数集

ApplicationObjectIdWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectIdWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-KeyCredentials

与应用程序关联的密钥凭据。

参数属性

类型:

MicrosoftGraphKeyCredential[]

默认值:None
支持通配符:False
不显示:False

参数集

ApplicationObjectIdWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ObjectId

应用程序的对象 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:Id

参数集

ApplicationObjectIdWithPasswordParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectIdWithCertValueParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectIdWithKeyCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectIdWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-PasswordCredentials

与应用程序关联的密码凭据。

参数属性

类型:

MicrosoftGraphPasswordCredential[]

默认值:None
支持通配符:False
不显示:False

参数集

ApplicationObjectIdWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithPasswordCredentialParameterSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-StartDate

凭据使用情况的有效开始日期。 默认开始日期值为今天。 对于“非对称”类型凭据,必须设置为 X509 证书有效日期或之后的日期。

参数属性

类型:DateTime
默认值:None
支持通配符:False
不显示:False

参数集

ApplicationObjectIdWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectIdWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationObjectWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DisplayNameWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithCertValueParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ApplicationIdWithPasswordParameterSet
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输入

IMicrosoftGraphApplication

输出

IMicrosoftGraphKeyCredential

IMicrosoftGraphPasswordCredential