1
votes

I have created an Azure Active Directory App Principal through Powershell. The app principal has a default client secret expiry period of one year. How to update the client secret after that expiry period?

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

1 Answers

1
votes

You are looking for the New-MsolServicePrincipalCredential. You don't update a secret but create a new one.

Are you aware that you are using the old MSOnline V1 PowerShell module for Azure Active Directory? You may consider to switch to the V2 module.