New-EntraApplicationPasswordCredential
为应用程序创建密码凭据。
语法
Default (默认值)
New-EntraApplicationPasswordCredential
-ApplicationId <String>
[-CustomKeyIdentifier <String>]
[-StartDate <DateTime>]
[-EndDate <DateTime>]
[<CommonParameters>]
说明
该 New-EntraApplicationPasswordCredential cmdlet 在 Microsoft Entra ID 中为应用程序创建密码凭据。
示例
示例 1:创建密码凭据
Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$application = Get-EntraApplication -Filter "displayName eq '<displayName>'"
$secret = New-EntraApplicationPasswordCredential -ApplicationId $application.Id
$secret | Format-List
CustomKeyIdentifier : 77 97 114 97 32 76 117 120 117 114 121...
Value : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
DisplayName : Contoso Automation account
EndDateTime : 5/9/2027 11:53:40 AM
Hint : WBB
KeyId : tttttttt-0000-2222-0000-aaaaaaaaaaaa
SecretText : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
StartDateTime : 5/9/2025 11:53:39 AM
此命令为指定的应用程序创建新的密码凭据。
-
-ApplicationId指定应用程序的 ID。
示例 2:使用 CustomKeyIdentifier 参数创建密码凭据
Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$application = Get-EntraApplication -Filter "displayName eq '<displayName>'"
$secret = New-EntraApplicationPasswordCredential -ApplicationId $application.Id -CustomKeyIdentifier '<userfriendlyDisplayName>'
$secret | Format-List
CustomKeyIdentifier : 77 97 114 97 32 76 117 120 117 114 121...
Value : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
DisplayName : Contoso Automation account
EndDateTime : 5/9/2027 11:53:40 AM
Hint : WBB
KeyId : tttttttt-0000-2222-0000-aaaaaaaaaaaa
SecretText : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
StartDateTime : 5/9/2025 11:53:39 AM
此命令为指定的应用程序创建新的密码凭据。
-
-ApplicationId指定应用程序的 ID。 -
-CustomKeyIdentifier指定唯一的二进制标识符。
示例 3:使用 StartDate 参数创建密码凭据
Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$application = Get-EntraApplication -Filter "displayName eq '<displayName>'"
$startDate = (Get-Date).AddYears(0)
$secret = New-EntraApplicationPasswordCredential -ApplicationId $application.Id -CustomKeyIdentifier '<userfriendlyDisplayName>' -StartDate $startDate
$secret | Format-List
CustomKeyIdentifier : 77 97 114 97 32 76 117 120 117 114 121...
Value : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
DisplayName : Contoso Automation account
EndDateTime : 5/9/2027 11:53:40 AM
Hint : WBB
KeyId : tttttttt-0000-2222-0000-aaaaaaaaaaaa
SecretText : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
StartDateTime : 5/9/2025 11:53:39 AM
此命令为指定的应用程序创建新的密码凭据。
-
-ApplicationId指定应用程序的 ID。 -
-StartDate指定密码生效的日期和时间。
示例 4:使用 EndDate 参数创建密码凭据
Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$application = Get-EntraApplication -Filter "displayName eq '<displayName>'"
$endDate = (Get-Date).AddYears(2)
$secret = New-EntraApplicationPasswordCredential -ApplicationId $application.Id -CustomKeyIdentifier '<userfriendlyDisplayName>' -EndDate $endDate
$secret | Format-List
CustomKeyIdentifier : 77 97 114 97 32 76 117 120 117 114 121...
Value : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
DisplayName : Contoso Automation account
EndDateTime : 5/9/2027 11:53:40 AM
Hint : WBB
KeyId : tttttttt-0000-2222-0000-aaaaaaaaaaaa
SecretText : wbBNW8kCuiPjNRg9NX98W_aaaaaaa
StartDateTime : 5/9/2025 11:53:39 AM
此命令为指定的应用程序创建新的密码凭据。
-
-ApplicationId指定应用程序的 ID。 -
-EndDate指定密码过期的日期和时间。
参数
-ApplicationId
指定Microsoft Entra ID中应用程序的 ID。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 对象标识符 (ObjectId) |
参数集
(All)
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-CustomKeyIdentifier
唯一的二进制标识符。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-EndDate
密码过期的日期和时间。
参数属性
| 类型: | System.DateTime |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-StartDate
密码生效的日期和时间。
参数属性
| 类型: | System.DateTime |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。