This post explains how to extend a Client ID / Client Secret pair using PowerShell.
Introduction
By default, a Client ID / Client Secret pair is only valid for 1 year. This post explains how to extend a client/secret using PowerShell, without the need for you to create a new Client ID / Client Secret pair.
The Code
#Client ID
$clientId = '0E03B46D-F2ED-4571-BAA4-79DB79227D41'
Connect-AzureAD
#Get the Client ID
$App = Get-AzureADServicePrincipal -All $true | Where-Object {$_.AppId -eq $clientId}
#Get the Current Expiry Date
$CurrentExpiryDate = (Get-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId).EndDate
Write-host "Current Expiry Date:"$CurrentExpiryDate
#Extend the validity of the App by 1 year
$StartDate = Get-Date
$EndDate = $StartDate.AddYears(1)
New-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId -StartDate $StartDate -EndDate $EndDate
The post Extending ClientID/Secret Expiration Date using PowerShell appeared first on Blog IT.
Top comments (0)