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

November 4, 2025
in Azure Active Directory, Blog, Microsoft Entra ID
0
ADVERTISEMENT

Table of Contents

Creating a Client Secret in the Microsoft Entra admin center usually has an expiration date of up to two years. Managing and renewing this Client Secret every two years can be inconvenient. Setting up a Client Secret that never expires would make things much simpler. This article walks you through how to create a perpetual Client Secret in Entra ID using PowerShell.

Client Secret in Entra ID

Credentials allow an application to authenticate on its own, removing the need for user interaction during runtime. To keep things simple, a Client Secret will be used as the credential type and incorporated into the app registration.

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

  1. In Entra ID, a Client Secret can have a maximum validity period of up to 24 months.
  2. You can create a Client Secret with PowerShell for an unlimited duration by using a script that sets the expiration date to indefinite. This effectively bypasses the default 24-month limit set 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 easily generate a new Client Secret using a PowerShell script without any limitations.

Register an application in Entra ID

How to sign up an app in the Microsoft Entra admin center.

1. Go to the Microsoft Entra admin center Then sign in to Microsoft Azure using your admin credentials.

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

JvCPGxv0VRN4s9D4YqCpSjaTflI7Ysyz9l59n9DILMv6JKyDKjF7HuKDC1gY

3. Register an application

  • Choose a name for your app that aligns with your needs.
  • Choose accounts exclusively within this organizational directory (single tenant).
  • Click on Register.
aNNRm71eb2FQgj9rUVnV2VFHQSOHFAOX0cuRDWHu4P4r5btoTVx1cV88jMj8

Once you’ve created the app, navigate to the Overview page and copy the Object ID. Save this ID in Notepad, as it will be needed later to generate an unlimited Client Secret using PowerShell.

kCuK6s0Yh9fVsvKyhmDpFUWjZVovOq31U45EChqu0N8704QGNVsM1fXDyB8X

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

Note Note:In Entra ID, Client Secrets have a maximum expiration period of 24 months (2 years), and it's not possible to select a longer duration when creating or renewing them. However, using PowerShell, you can set an expiration date without any limitations.

Follow these steps to create a Client Secret for your application in Entra ID:

  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. Be sure to copy the Client Secret value and keep it stored safely.

Note Note: Client secret values are only visible immediately after creation, so be sure to save them before navigating away from the page.
1lpHcdCaGv5cf9Bj4F02mArs8mTF469qsMm2180aeV2lYrkcXFKNq9ysxCO0

Create a never-expired client secret with PowerShell

Once you’ve registered an application, you can use PowerShell to generate a Client Secret with no expiration date.

1. Launch Windows PowerShell (Terminal) with administrative privileges, and execute the following command to install the necessary Microsoft Graph PowerShell module.

Install-Module Microsoft.Graph.Applications -Scope CurrentUser

2. Copy the script below and paste it into your favorite text editor. Don’t forget 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 prepared. Just copy and paste it into the PowerShell window, then log 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 show the SecretText (Client Secret Value). Make sure to copy and securely store the SecretText (Client Secret Value).

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 can only be accessed immediately after creation, so be sure to save them before closing the PowerShell window.

6. Go to the Microsoft Entra admin center to verify that the secret has been created successfully.

AY49QFjT1MlWKJ4nlpH5QSiTfoQ5H3qkkuoQNgJrKb7S0vbpUI2JepcwBBjl

The new Client Secret has been created with a 50-year expiration period. You’ve successfully configured a Client Secret for your Microsoft Azure application without an expiration date.

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