The Add-MgApplicationPassword cmdlet creates and assigns a new password credential to a specific application registered in Microsoft Entra ID (previously Azure AD). This cmdlet is essential when applications require client secrets for authentication.
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Application.ReadWrite.All"
Run the following Graph PowerShell command below to add a password (client secret) to an application. Replace <application-id> with the object ID or GUID of the application, and <object> with the properties for the new password credential:
Add-MgApplicationPassword -ApplicationId <application-id> -PasswordCredential <object>
This Graph PowerShell command adds a password credential with the display name "MyAppSecret" to the specified application:
Add-MgApplicationPassword -ApplicationId "12345678-90ab-cdef-1234-567890abcdef" -PasswordCredential @{ displayName="MyAppSecret" }
This Graph PowerShell command creates a new password credential with a specified value:
Add-MgApplicationPassword -ApplicationId "12345678-90ab-cdef-1234-567890abcdef" -PasswordCredential @{ displayName="Secret2"; secretText="CustomPassword123!" }
The following are some essential parameters that can be used along with the Add-MgApplicationPassword command:
| Parameters | Description |
|---|---|
| -ApplicationId | The object ID or unique identifier for the application |
| -PasswordCredential | Specifies properties of the new password credential (e.g., displayName, endDateTime) |
| -PassThru | Returns the created password credential object |
| -WhatIf | Shows what would happen if the cmdlet ran, without executing it |
| -Confirm | Prompts for confirmation before running the cmdlet |
ADManager Plus, an identity governance and administration solution with comprehensive Microsoft Entra ID management and reporting capabilities, simplifies complex admin tasks from a single, user-friendly console: