DEV Community

Miguel Isidoro
Miguel Isidoro

Posted on • Originally published at blogit.create.pt on

Extending ClientID/Secret Expiration Date using PowerShell

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



Enter fullscreen mode Exit fullscreen mode

The post Extending ClientID/Secret Expiration Date using PowerShell appeared first on Blog IT.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay