Azure Active Directory应用程序服务主体更新客户端密钥

时间:2018-02-16 18:40:28

标签: azure azure-active-directory

我通过Powershell创建了一个Azure Active Directory App Principal。应用程序主体的默认客户端密钥有效期为一年。到期后如何更新客户机密?

PS C:\Users\user> $msolcred = Get-Credential

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential

PS C:\Users\user>  Connect-MsolService -credential $msolcred

PS C:\Users\user> $bytes = New-Object Byte[] 32

PS C:\Users\user> $rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()

PS C:\Users\user>  $rand.GetBytes($bytes)

PS C:\Users\user> $rand.Dispose()

PS C:\Users\user>  $newClientSecret = [System.Convert]::ToBase64String($bytes)

PS C:\Users\user> New-MsolServicePrincipal -DisplayName "DemoSP" -Type password -Value $newClientSecret



DisplayName           : DemoSP

ServicePrincipalNames : {6e2b0328-87b3-459f-a874-e9e76704c71f}

ObjectId              : 525da0c9-6548-42ea-a2ce-457bd42c0cfa

AppPrincipalId        : 6e2b0328-87b3-459f-a874-e9e76704c71f

TrustedForDelegation  : False

AccountEnabled        : True

Addresses             : {}

KeyType               : Password

KeyId                 : 6f15cddf-5ffd-448d-b359-be4756e6165e

StartDate             : 3/29/2017 6:18:33 PM

EndDate               : 3/29/2018 6:18:33 PM

Usage                 : Verify

1 个答案:

答案 0 :(得分:1)

您正在寻找New-MsolServicePrincipalCredential。您不会更新机密,但会创建一个新机密。

您是否知道您使用旧的MSOnline V1 PowerShell模块进行Azure Active Directory?您可以考虑切换到V2 module.