How to use Powershell Graph module with custom payload

Howdy,

this took me about a lot more time then it should, simply because there are no examples of this online and none of the other Azure related modules previously did this to me. So the scenario is: you need to update an Azure AD Application with multiple values and you need to do it in 1 go. you can use Update-MgApplication with the -BodyParameter. If you know how to do that :)

$app = Get-AzADApplication -DisplayName $Registration.DisplayName
# graph module needs to be imported for this to work
$appSettings = [Microsoft.Graph.PowerShell.Models.MicrosoftGraphApplication1]@{}
$appSettings.Id = $app.Id
# here you can update other properties
$appSettings.Web.ImplicitGrantSettings.EnableIdTokenIssuance = $true
$appSettings.IsFallbackPublicClient = $false
# after that you can actually update the app
Update-MgApplication -BodyParameter $appSettings -ApplicationId $app.id

couple of other weird things about these cmdlets:

  • they don’t error out when you create a hash table and feed it to them (but they don’t do anything)
  • when you add -Debug they don’t show the body they are actually sending

combination of these 2 above makes you believe you did everything right. but nothing changes.

Happy deploying!

Written on March 25, 2022