Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Create an Unlimited Client Secret in Microsoft Entra ID

October 28, 2025
in Azure Active Directory, Blog, Microsoft Entra ID
0
ADVERTISEMENT

Table of Contents

Creating a Client Secret in the Microsoft Entra admin center typically comes with an expiration date of up to two years. Renewing and managing this Client Secret every two years can be a hassle. It would be much easier if you could create a Client Secret that never expires. This article explains how to set up a perpetual Client Secret in Entra ID using PowerShell.

Client Secret in Entra ID

Credentials enable an application to authenticate independently, eliminating the need for user interaction during runtime. For simplicity, a Client Secret will be used as the credential type and integrated into the app registration.

You can create a client secret for an application by either generating it through the application’s settings in the Azure portal or using PowerShell for a more automated method.

  1. The maximum validity period for a Client Secret in Entra ID is limited to 24 months.
  2. It is possible to create a Client Secret with PowerShell for an unlimited duration. This can be done using a PowerShell script that sets the expiration date to an indefinite period, effectively bypassing the default 24-month limit imposed by the Microsoft Entra ID portal.

If you need to renew a Client Secret for an application in Entra ID, there’s no need to create a new one. You can use a PowerShell script to generate a Client Secret without any restrictions.

Register an application in Entra ID

How to register an app in the Microsoft Entra admin center.

1. Go to the Microsoft Entra admin center then Sign in to Microsoft Azure with your admin credentials

2. Expand the Applications menu > Click App registrations > New registration.

JvCPGxv0VRN4s9D4YqCpSjaTflI7Ysyz9l59n9DILMv6JKyDKjF7HuKDC1gY

3. Register an application

  • Pick a name for your app that fits your requirements.
  • Select accounts in this organizational directory only (single tenant).
  • Click on Register.
aNNRm71eb2FQgj9rUVnV2VFHQSOHFAOX0cuRDWHu4P4r5btoTVx1cV88jMj8

After creating the app, go to the Overview page and copy the Object ID. Save this ID in Notepad, as you’ll need it later to create an unlimited Client Secret with PowerShell.

kCuK6s0Yh9fVsvKyhmDpFUWjZVovOq31U45EChqu0N8704QGNVsM1fXDyB8X

Create a Client Secret for application in Entra ID (Optional)

Note Note: In Entra ID, the expiration date for a Client Secret is limited to a maximum of 24 months (2 years), and you can't choose a longer period when creating or renewing it. However, with PowerShell, you can set an expiration date without any restrictions.

To create a Client Secret for your application in Entra ID, follow these steps:

  1. Click on Certificates & secrets
  2. Click Client secrets > New client secret
  3. Type the description
  4. Select an expiration date
  5. Click Add
xg4JxLr1vMe7E2S4KGaUs9asFHjYlf1sk5AeWzadlTaRcEkMRCdB444ecxg8

6. Make sure to copy the Client Secret value and store it securely.

Note Note: You can only view client secret values right after they are created, so make sure to save them before you leave the page.
1lpHcdCaGv5cf9Bj4F02mArs8mTF469qsMm2180aeV2lYrkcXFKNq9ysxCO0

Create a never-expired client secret with PowerShell

After registering an application, you can use PowerShell to create a Client Secret that doesn’t have an expiration date.

1. Open Windows PowerShell (Terminal) as an administrator and run the following command to install the required Microsoft Graph PowerShell module.

Install-Module Microsoft.Graph.Applications -Scope CurrentUser

2. Copy the script below and paste it into your preferred text editor. Make sure to replace the Object ID you copied earlier during the app registration process.

# Connect to Microsoft Graph
Connect-MgGraph -Scopes 'Application.ReadWrite.All'

# Parameters
$AppObjectId = "xxxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxx"
$AppSecretDescription = "Never expired client secret"
$AppYears = "50"

$PasswordCred = @{
    displayName = $AppSecretDescription
    endDateTime = (Get-Date).AddYears($AppYears)
}

# Add App Client Secret - Valid for 50 years (change to 999 for unlimited years)
$Secret = Add-MgApplicationPassword -ApplicationId $AppObjectId -PasswordCredential $PasswordCred

# Write Client Secret value
$Secret | Format-List

3. The code is ready. Simply copy and paste it into the PowerShell window, then sign in using your global administrator credentials.

4. Select Consent on behalf of your organization then Click the Accept button.

nYp8CLMhxjkm7iUZkDIXb6GXPwAJvqR6h65zDwqJsKxeWyVpEGyEoxbeOIOU

5. The PowerShell output will display the SecretText (Client Secret Value). Be sure to copy the SecretText (Client Secret Value) and store it in a secure location.

PS C:\> $Secret | Format-List

CustomKeyIdentifier  :
DisplayName          : Never expired client secret
EndDateTime          : 1/19/2074 3:00:18 AM
Hint                 : tFs
KeyId                : 9fffb36d-788d-437f-b10b-f986e5fd0a47
SecretText           : tFs8Q~VJBO8Yrgq6gFxexUfyLRWuIfAXin7jYbKl
StartDateTime        : 1/19/2024 3:00:20 AM
AdditionalProperties : {[@odata.context,
                       https://graph.microsoft.com/v1.0/$metadata#microsoft.graph....]}
Note Note: Client secret values are only accessible right after they are created, so make sure to save the secret before closing the PowerShell window.

6. Head over to the Microsoft Enter admin center to confirm that the secret has been successfully created.

AY49QFjT1MlWKJ4nlpH5QSiTfoQ5H3qkkuoQNgJrKb7S0vbpUI2JepcwBBjl

The new Client Secret has been created and is set to expire in 50 years. You’ve successfully set up a Client Secret for your Microsoft Azure application with no expiration date.

Conclusion

This guide explains how to create a non-expiring Client Secret in Entra ID using PowerShell, eliminating the need for periodic renewals.

ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (2 votes)
Previous Post

How to Check the Language Code of a Windows ISO Image

Next Post

How to Verify Azure AD Tenant Availability

Related Posts

How To Upgrade Windows Server Evaluation To Full Version

October 21, 2025

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

Leave a Reply Cancel reply

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

Recent Posts

  • How To Upgrade Windows Server Evaluation To Full Version
  • Must Have Remediation Scripts In Microsoft Intune
  • How To Turn On uBlock Origin Extension in Chrome (2025)

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory