Skip to content

Instantly share code, notes, and snippets.

@Nillth
Created August 26, 2022 04:24
Show Gist options
  • Save Nillth/0fbe31abc82ab93b44af81057f9a9371 to your computer and use it in GitHub Desktop.
Save Nillth/0fbe31abc82ab93b44af81057f9a9371 to your computer and use it in GitHub Desktop.
Cleans up a SAML IDP Metadata file to remove the RoleDescriptor nodes
<#
.NOTES
===========================================================================
Created on: 2022-08-26 2:21 PM
Created by: Marc Collins
Organization: Qlik Customer Success
Filename: SAML_Remove_RoleDescriptors.ps1
===========================================================================
.DESCRIPTION
Removes the RoleDescriptor nodes from a XML file and resaves
Resolved https://support.qlik.com/articles/000052086
#>
$NewMetaDataFile = "\\path\to\IDPMetadata.xml"
$IDPXML = New-Object xml
$IDPXML.Load($NewMetaDataFile)
$IDPNS = New-Object Xml.XmlNamespaceManager $IDPXML.NameTable
$IDPNS.AddNamespace('idp', $IDPXML.EntityDescriptor.xmlns)
$RD = $IDPXML.SelectNodes("//idp:RoleDescriptor", $IDPNS)
$RD | ForEach-Object{
$_.ParentNode.RemoveChild($_)
}
$IDPXML.Save($NewMetaDataFile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment