Description
Question:
When trying to issue this command:
New-MgDeviceManagementDeviceConfiguration -DisplayName "Test" -AdditionalProperties $myhash
´
it fails with
Property omaSettings in payload has a value that does not match schema.
This is how I have constructed $myhash;
[byte[]] $omaxml_bytearr = get-content -Path C:\Temp\omaxml.xml -AsByteStream
$omaxml_b64 = [System.Convert]::ToBase64String($omaxml_bytearr)
$mydict = New-Object -TypeName 'System.Collections.Generic.Dictionary`2[[string]'
$mydict.Add('@odata.type','#microsoft.graph.omaSettingStringXml')
$mydict.Add('displayName','LocalUsersAndGroups /Configure /R')
$mydict.Add('omaUri','./Device/Vendor/MSFT/Policy/Config/LocalUsersAndGroups/Configure')
$mydict.Add('fileName','OmaXML.xml')
$mydict.Add('value',"$omaxml_b64")
$myhash = @{
'@odata.context' = 'https://graph.microsoft.com/v1.0/$metadata#deviceManagement/deviceConfigurations/$entity'
'@odata.type' = '#microsoft.graph.windows10CustomConfiguration'
}
$myhash.Add('omaSettings',$mydict)
When checking how it "should" look by issuing:
Get-MgDeviceManagementDeviceConfiguration -DeviceConfigurationId "<some-guid>" -OutVariable getdevconfig
and then running
$getdevconfig.AdditionalProperties.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Dictionary`2 System.Object
and
$getdevconfig.AdditionalProperties.omaSettings.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array`
the actual request that works in Graph API Explorer:
{
"@odata.type": "#microsoft.graph.windows10CustomConfiguration",
"description": "Description value",
"displayName": "[Test-GraphAPI] LocalAdminCustom",
"version": 7,
"omaSettings": [
{
"@odata.type": "#microsoft.graph.omaSettingStringXml",
"displayName": "LocalUsersAndGroups /Configure /R",
"omaUri": "./Device/Vendor/MSFT/Policy/Config/LocalUsersAndGroups/Configure",
"fileName": "Custom_Administrators_LocalUsersAndGroups.xml",
"value": "ICAgICAgICA8R3JvdXBDb25maWd1cmF0aW9uPg0KICAgICAgICAgICAgPGFjY2Vzc2dyb3VwIGRlc2MgPSAiQWRtaW5pc3RyYXRvcnMiPg0KICAgICAgICAgICAgICAgIDxncm91cCBhY3Rpb24gPSAiUiIgLz4NCiAgICAgICAgICAgICAgICA8YWRkIG1lbWJlciA9ICJBZG1pbmlzdHJhdG9yIi8+DQogICAgICAgICAgICA8L2FjY2Vzc2dyb3VwPg0KICAgICAgICA8L0dyb3VwQ29uZmlndXJhdGlvbj4NCg=="
}
]
}
Link for request above:
https://docs.microsoft.com/en-us/graph/api/intune-deviceconfig-windows10customconfiguration-create?view=graph-rest-1.0
Using the code below I can successfully create a configuration but the actual settings for "OMA-URI Settings" is empty;
[byte[]] $omaxml_bytearr = get-content -Path C:\Temp\omaxml.xml -AsByteStream
$omaxml_b64 = [System.Convert]::ToBase64String($omaxml_bytearr)
$omasettings = @{
'@odata.type' = '#microsoft.graph.omaSettingStringXml'
'displayName' = 'LocalUsersAndGroups /Configure /R'
'omaUri' = './Device/Vendor/MSFT/Policy/Config/LocalUsersAndGroups/Configure'
'fileName' = 'Custom_Administrators_LocalUsersAndGroups.xml'
'value' = $omaxml_b64
}
$additionalproperties = @{
'@odata.type' = '#microsoft.graph.windows10CustomConfiguration'
'omaSettings' = $omasettings
}
New-MgDeviceManagementDeviceConfiguration -DisplayName "Test" -AdditionalProperties $additionalproperties
I can't really figure out how to solve this, any help?
Best Regards