rieskaniemi.com

yet another it blog

Generate long Azure application secrets using PowerShell

Azure portal limits secrets to expire every 2 years. Using PowerShell you can bypass this limit and create secrets past 2 years limit

First install Azure AD PowerShell module if not already installed.

Install-Module AzureAD

After installation connect to Azure AD and run following commands to create new secret. In our example we create secret that is valid for 10 years. Adjust $endDate = $startDate.AddYears(10) accordingly:

Connect-AzureAD

$startDate = Get-Date
$endDate = $startDate.AddYears(10)
$value = New-AzureADApplicationPasswordCredential -ObjectId "REPLACE_WITH_OBJECTID_OF_APP_REGISTRATION"-StartDate $startDate -EndDate $endDate

$value

Object ID can be found under app properties in Azure AD.

Tagged

Leave a Reply

Your email address will not be published. Required fields are marked *