This post outlines how to extend a Client ID / Client Secret pair using PowerShell.

Introduction
By default, a Client ID / Client Secret pair is valid for just one year. This guide will show you how to extend your client/secret using PowerShell, eliminating the need to generate a new pair. Please note that Microsoft will soon discontinue support for this type of app, allowing extensions solely for legacy reasons.

#Application ID
$ClientID =  "" #Place your Client Id Here
$ClientSecret = "" #Place your Client Secret Here
 
#Connect to AzureAD
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 -Value $ClientSecret
New-AzureADServicePrincipalKeyCredential -ObjectId $App.ObjectId -StartDate $StartDate -EndDate $EndDate -Value $ClientSecret
$NewExpiryDate = (Get-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId).EndDate
Write-Host "New Expiry Date: "$NewExpiryDate