共用方式為


New-AzureRmADAppCredential

將認證新增至現有的應用程式。

警告

自 2024 年 2 月 29 日起,AzureRM PowerShell 模組已正式淘汰。 建議使用者從 AzureRM 遷移至 Az PowerShell 模組,以確保持續支援和更新。

雖然 AzureRM 模組可能仍可運作,但不再維護或支援它,但會根據用戶的判斷權和風險放置任何繼續使用。 如需轉換至 Az 模組的指引,請參閱我們的 移轉資源

Syntax

New-AzureRmADAppCredential
   -ObjectId <Guid>
   -Password <SecureString>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -ObjectId <Guid>
   -CertValue <String>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -ApplicationId <Guid>
   -CertValue <String>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -ApplicationId <Guid>
   -Password <SecureString>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -DisplayName <String>
   -Password <SecureString>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -DisplayName <String>
   -CertValue <String>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -ApplicationObject <PSADApplication>
   -CertValue <String>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzureRmADAppCredential
   -ApplicationObject <PSADApplication>
   -Password <SecureString>
   [-StartDate <DateTime>]
   [-EndDate <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

New-AzureRmADAppCredential Cmdlet 可用來新增認證或為應用程式變換認證。 應用程式是藉由提供應用程式物件標識碼或應用程式標識碼來識別。

範例

範例 1 - 使用密碼建立新的應用程式認證

PS C:\> $SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force
PS C:\> New-AzureRmADAppCredential -ObjectId 1f89cf81-0146-4f4e-beae-2007d0668416 -Password $SecureStringPassword

新的密碼認證會新增至具有對象標識碼 '1f89cf81-0146-4f4e-beae-2007d0668416' 的現有應用程式。

範例 2 - 使用憑證建立新的應用程式認證

PS C:\> $cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate 
PS C:\> $cer.Import("C:\myapp.cer") 
PS C:\> $binCert = $cer.GetRawCertData() 
PS C:\> $credValue = [System.Convert]::ToBase64String($binCert)
PS C:\> New-AzureRmADAppCredential -ApplicationId 4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58 -CertValue $credValue -StartDate $cer.GetEffectiveDateString() -EndDate $cer.GetExpirationDateString()

提供的base64編碼公用 X509 憑證 (“myapp.cer”) 會新增至具有應用程式標識碼 '4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58' 的現有應用程式。

範例 3 - 使用管線建立新的應用程式認證

PS C:\> $SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force
PS C:\> Get-AzureRmADApplication -ObjectId 1f89cf81-0146-4f4e-beae-2007d0668416 | New-AzureRmADAppCredential -Password $SecureStringPassword

取得物件標識符為 '1f89cf81-0146-4f4e-beae-2007d0668416' 的應用程式,並使用管線將它傳送至 New-AzureRmADAppCredential,為該應用程式建立具有指定密碼的新應用程式認證。

參數

-ApplicationId

要加入認證之應用程式的應用程式識別碼。

類型:Guid
Position:Named
預設值:None
必要:True
Accept pipeline input:True
Accept wildcard characters:False

-ApplicationObject

要加入認證的應用程式物件。

類型:PSADApplication
Position:Named
預設值:None
必要:True
Accept pipeline input:True
Accept wildcard characters:False

-CertValue

「非對稱」認證類型的值。 它代表基底 64 編碼的憑證。

類型:String
Position:Named
預設值:None
必要:True
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

執行 Cmdlet 之前先提示您確認。

類型:SwitchParameter
Aliases:cf
Position:Named
預設值:False
必要:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶

類型:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
Accept pipeline input:False
Accept wildcard characters:False

-DisplayName

應用程式的顯示名稱。

類型:String
Position:Named
預設值:None
必要:True
Accept pipeline input:True
Accept wildcard characters:False

-EndDate

認證使用方式的有效結束日期。 默認結束日期值是從今天起的一年。 對於「非對稱」類型認證,這必須設定為 X509 憑證有效日期或之前。

類型:DateTime
Position:Named
預設值:None
必要:False
Accept pipeline input:True
Accept wildcard characters:False

-ObjectId

要加入認證之應用程式的物件識別碼。

類型:Guid
Position:Named
預設值:None
必要:True
Accept pipeline input:True
Accept wildcard characters:False

-Password

要與應用程式相關聯的密碼。

類型:SecureString
Position:Named
預設值:None
必要:True
Accept pipeline input:True
Accept wildcard characters:False

-StartDate

認證使用方式的有效開始日期。 默認開始日期值是今天。 針對「非對稱」類型認證,這必須設定為 X509 憑證的有效日期或之後。

類型:DateTime
Position:Named
預設值:None
必要:False
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

類型:SwitchParameter
Aliases:wi
Position:Named
預設值:False
必要:False
Accept pipeline input:False
Accept wildcard characters:False

輸入

Guid

String

PSADApplication

參數:ApplicationObject (ByValue)

SecureString

DateTime

輸出

PSADCredential