We have a SharePoint app that connects our order processing systems to SharePoint. As the expiration date was coming up soon (5/2), I used a simple Power Shell script to replace the expiration date with one in the future:
Connect-AzureAD
$App = Get-AzureADServicePrincipal -All $true | Where-Object {$_.AppID -eq '<APP ID>'}
$StartDate = Get-Date $EndDate = $StartDate.AddYears(10) New-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId -StartDate $StartDate -EndDate $EndDate
This did generate a new expiration date, but instead of replacing the existing expiration date, it was appended to the app's details. The app seems to only see the expired date and errors saying the client secret is expired.
I tried generating a new secret using the script here: https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in But that script is out of date (refers to Msol instead of AzureAd) and errors when updated and ran it. It did return a new client secret but again appended yet another expiration date to the to the app. I tried this twice and now my app has 4 expiration dates
PS C:\Users\agutierrez] Write-host "Current Expiry Date:"$CurrentExpiryDate Current Expiry Date: 5/3/2033 10:15:52 3/23/2033 02:35:13 5/11/2025 02:37:56
5/2/2023 09:53:03
I would like to somehow update this app to remove all but the 5/3/2033 expiration date. If that's not possible, then I would like to have the expiration date set for one year, and be given up to date powershell scripts to generate a new secret in one year's time. This is urgent, as it's affecting our ability to process orders and their associated files and I've been unable to get a response from Microsoft since submitting a help request 18 hours ago.