将证书上传到 AAD 应用程序的 powershell 命令是什么?

Thr*_*ror 4 powershell azure azure-active-directory

在Azure门户中,我可以在AAD下创建一个应用程序,导航到“主页(myTenant)->应用程序注册->(myApp)->设置->密钥”,上传作为应用程序密钥证书的公钥。使用门户 UI 可以轻松实现这一点。但是如何使用Powershell命令上传证书呢?

谢谢,

小智 5

您正在寻找命令 New-AzureRmADAppCredential https://learn.microsoft.com/en-us/powershell/module/azurerm.resources/new-azurermadappcredential?view=azurermps-5.0.0

文章中的示例 2 应该适合您

----------------8<--------------------

$cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate 
$cer.Import("C:\myapp.cer") 
$binCert = $cer.GetRawCertData() 
$credValue = [System.Convert]::ToBase64String($binCert)

New-AzureRmADAppCredential -ApplicationId 4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58 -CertValue $credValue -StartDate $cer.GetEffectiveDateString() -EndDate $cer.GetExpirationDateString()
Run Code Online (Sandbox Code Playgroud)