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?
CodePudding user response:
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:
To confirm the above, check the portal like below:
Go to Azure Portal -> Azure Active Directory -> App Registrations -> Your App -> Certificates & secrets
Reference:
New-AzureADApplicationPasswordCredential (AzureAD) | Microsoft Docs