3.10.1.10

Issue 380 - ADMX Import / Reg Values fails because of XML format.
This commit is contained in:
Mikael Karlsson
2025-11-24 21:56:42 +11:00
parent 7657fac645
commit 7b87325776
2 changed files with 68 additions and 9 deletions
+47 -9
View File
@@ -55,10 +55,25 @@ function Invoke-InitializeModule
<elements>
</elements>
</policy>
</policy>
</policies>
</policyDefinitions>
"@
"@
# Add settings
$global:appSettingSections += (New-Object PSObject -Property @{
Title = "Intune Tools"
Id = "IntuneTools"
Values = @()
})
Add-SettingsObject (New-Object PSObject -Property @{
Title = "Format OM-URI Settings"
Key = "FormatOMAURI"
Type = "Boolean"
DefaultValue = $false
Description = "Formats the XML for OMA-URI settings e.g. removes unnecessary spaces and empty lines."
}) "IntuneTools"
}
function Add-EMToolsViewItem
@@ -1053,6 +1068,7 @@ function Set-ADMXElementsPanel
Write-Log "Unsupported value type for $($elementNode.Id): $($valItem.value.InnerXml)" 2
$value = "<SET MANUALLY!!!>"
}
$valItems += [PSCustomObject]@{
Name = $displayName
Value = $value
@@ -1408,18 +1424,23 @@ function Import-ADMXPolicy
{
if($admxPolicy.SettingStatus -eq 0)
{
$policyValue = "<disabled />"
$policyValue = "<disabled/>"
}
else
{
$policyValue = "<enabled />"
$policyValue = "<enabled/>"
$strValue = $admxPolicy.PolicySettings
if($strValue)
{
$policyValue += "`n`n$strValue"
}
$policyValue += "`n$strValue"
}
}
if((Get-SettingValue "FormatOMAURI") -eq $true)
{
$policyValue = Update-XmlFormatting $policyValue
}
$catPath = Get-ADMXCategoryOMAURIPath $admxPolicy.Definition.parentCategory.ref
@@ -1463,12 +1484,18 @@ function Import-ADMXPolicy
if($global:chkADMXPolicyIngest.IsChecked)
{
$xmlString = Format-XML $script:admxXML
if((Get-SettingValue "FormatOMAURI") -eq $true)
{
$xmlString = Update-XmlFormatting $xmlString
}
$intuneObj.omaSettings += [PSCustomObject]@{
"@odata.type" = "#microsoft.graph.omaSettingString"
"displayName" = (?? $global:txtADMXPolicyIngestName.Text ("$($script:currentADMXFile.Name) Ingestion"))
"description" = $null
"omaUri" = "./Device/Vendor/MSFT/Policy/ConfigOperations/ADMXInstall/$($global:txtADMXPolicyAppName.Text)/Policy/$($global:txtADMXPolicyFileName.Text)"
"value" = (Format-XML $script:admxXML)
"value" = $xmlString
}
}
@@ -1785,7 +1812,7 @@ function Get-ADMXRegIsKeySupported
if($blockedSource)
{
[System.Windows.MessageBox]::Show("The registry key '$($global:txtADMXRegKey.Text)' is not supported" + [Environment]::NewLine + [Environment]::NewLine + "Blocked by root key: $blockedSource", "Unsupported reg ket", "OK", "Error")
[System.Windows.MessageBox]::Show("The registry key '$($global:txtADMXRegKey.Text)' is not supported" + [Environment]::NewLine + [Environment]::NewLine + "Blocked by root key: $blockedSource", "Unsupported reg key", "OK", "Error")
return $false
}
return $true
@@ -1932,6 +1959,11 @@ function Import-ADMXRegProfile
$OMAURIString = ($OMAURIString + [Environment]::NewLine + [Environment]::NewLine + ($omaUriItems -join [Environment]::NewLine))
}
if((Get-SettingValue "FormatOMAURI") -eq $true)
{
$OMAURIString = Update-XmlFormatting $OMAURIString
}
$xml.policyDefinitions.SelectSingleNode("policies").AppendChild($newNode) | Out-Null
$admxRegSettings += [PSCustomObject]@{
@@ -1944,12 +1976,18 @@ function Import-ADMXRegProfile
$xml.policyDefinitions.SelectSingleNode("policies").RemoveChild($xml.policyDefinitions.policies.SelectSingleNode("policy")) | Out-Null
$xmlString = Format-XML $xml
if((Get-SettingValue "FormatOMAURI") -eq $true)
{
$xmlString = Update-XmlFormatting $xmlString
}
$intuneObj.omaSettings += [PSCustomObject]@{
"@odata.type" = "#microsoft.graph.omaSettingString"
"displayName" = "Reg ADMX Ingestion"
"description" = "This XML is generated by Intune Managemet tool"
"omaUri" = "./Device/Vendor/MSFT/Policy/ConfigOperations/ADMXInstall/IntuneManagementReg/$(($script:frmADMXRegProfile.DataContext.PolicyType))/$($rgPolicyFileName)"
"value" = (Format-XML $xml)
"value" = $xmlString
}
$intuneObj.omaSettings += $admxRegSettings