12 April 2023

Create an Azure AD app client secret with long expiration date

After creating the app, note the app's ObjectID and use AzureAD PowerShell:

$StartDate = Get-Date
$EndDate = $StartDate.AddYears(40)
$AppSecret = New-AzureADApplicationPasswordCredential -ObjectId abcdefab-1234-abcd-abcd-123456789012 -StartDate $StartDate -EndDate $EndDate -CustomKeyIdentifier MySecretKey
Write-host $AppSecret.Value

This creates a client secret called "MySecretKey" that's valid for 40 years. The last line outputs the secret itself - take note of it as you won't be able to see it again.

No comments:

Post a Comment