Forum Discussion
mvolkmann
Jul 03, 2024Copper Contributor
Renew App registration secret with Powershell
Hello everyone,
is it possible to create a new secret for an existing app registration via powershell?
Thanks for tips and suggestions in advance!
- SebastiaanSmitsSteel Contributor
You can use the API endpoint with method POST (App ID is obscured):
$url = "https://graph.microsoft.com/v1.0/myorganization/applications/057702ab-3ea0-****-***-*******/addPassword" $appAssignmentHashtable = @{} $appAssignmentHashtable.mobileAppAssignments = @([ordered]@{ "passwordCredential"= [ordered]@{ "displayname"= "TestTN"; "endDateTime"= "2024-12-30T10:27:35.455Z"; "startDateTime"= "2024-07-03T09:27:35.455Z" }; }) $appAssignmentJSON = $appAssignmentHashtable | ConvertTo-Json -depth 10 $body= $appAssignmentJSON -replace '""','null' Invoke-MgGraphRequest -Uri $url -Body $body -Method POST -OutputType PSObject
There is also a new Entra Module that can perform this:
New-EntraApplicationPasswordCredential -ObjectId "057702ab-3ea0-******-******"
See here more information: