Renew App registration secret with Powershell

Copper Contributor

Hello everyone,

 

is it possible to create a new secret for an existing app registration via powershell?

 

Thanks for tips and suggestions in advance!

 

 

1 Reply

@mvolkmann 

 

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:

 

https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.entra/new-entraapplicationpasswo...

 

https://techcommunity.microsoft.com/t5/microsoft-entra-blog/introducing-the-microsoft-entra-powershe...