Anderson
Anderson

Reputation: 23

Unable to create client secret from Powershell

My requirement is to create an Azure Active Directory Application and a client secret for that application via Powershell. I know how to do it via Azure Portal. To create an Azure Active Directory Application I found this command:

New-AzureADApplication -DisplayName DemoApp

This successfully created an Application. But my problem is with client secret. Is there is any command to do this?

Upvotes: 2

Views: 450

Answers (1)

Sridevi
Sridevi

Reputation: 22352

You can create client secret by using the below PowerShell cmdlet:

New-AzureADApplicationPasswordCredential -CustomKeyIdentifier SecretName -ObjectId Your_Object_Id -EndDate ((Get-Date).AddMonths(6))

I tried to reproduce the same in my environment and was able to create client secret successfully for the Azure AD application like below:

enter image description here

To confirm the above, check the portal like below:

Go to Azure Portal -> Azure Active Directory -> App Registrations -> Your App -> Certificates & secrets

image

Reference:

New-AzureADApplicationPasswordCredential (AzureAD) | Microsoft Docs

Upvotes: 2

Related Questions