'AAD B2C - Upload custom policy file using Microsoft.Graph module on Powershell
I'm using the latest Powershell (currently v.7.2.2) with the Microsoft.Graph module to automate several tasks on AAD B2C. I'm currently stuck on uploading new policies https://docs.microsoft.com/en-us/powershell/module/microsoft.graph.identity.signins/new-mgtrustframeworkpolicy?view=graph-powershell-beta
I couldn't find any examples on how to use the New-MgTrustFrameworkPolicy function anywhere. Following the documentation I tried:
New-MgTrustFrameworkPolicy -Id "B2C_1A_mypolicy"
New-MgTrustFrameworkPolicy -BodyParameter @{trustFrameworkPolicy = "B2C_1A_mypolicy"}
New-MgTrustFrameworkPolicy -BodyParameter @{trustFrameworkPolicy = "<?xml version='1.0' encoding='utf-8' ?><TrustFrameworkPolicy ...'/>"}
New-MgTrustFrameworkPolicy -BodyParameter @{trustFrameworkPolicy = "<policy file path>"}
But everytime I got this error back:
New-MgTrustFrameworkPolicy_Create: The policy being uploaded is not XML or is not correctly formatted: Data at the root level is invalid. Line 1, position 1.
Having said that, I'm able to update the policy content if I upload the policy manually (through the Azure Portal) and then use:
Set-MgTrustFrameworkPolicyContent -TrustFrameworkPolicyId "B2C_1A_mypolicy" -InFile "<policy file path>"
I am aware that I can do this using older Powershell modules. However, I would like to use the new Microsoft.Graph module. New-MgTrustFrameworkPolicy seems like the right function to use. I'm just not sure how exactly to use it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
