2

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?

James Z
  • 12,209
  • 10
  • 24
  • 44
Anderson
  • 23
  • 4

1 Answers1

2

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

Sridevi
  • 10,599
  • 1
  • 4
  • 17