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.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more