_template XML Editing Template Powershell - superseded
Log In or Register to download the BES file, and more.

0 Votes

Versioning - This is an older version.

1_template XML Editing Template Powershell11/12/2018 10:45:08 AM
2_template XML Editing Template Powershell11/12/2018 10:49:01 AM


Sample template fixlet to modify an XML file. 

This Fixlet demonstrates opening an XML file with PowerShell, and replacing a value in the XML content.

Originally written to allow removing an NVidia driver without rebooting.  NVidia, in their admin-unfriendliness, decided that uninstalling a driver should immediately trigger a reboot without providing any options to delay the reboot or to warn the user that a reboot is going to occur.  There are no command-line parameters available to modify this behavior, but we can skip the reboot by modifying a value in their nv.xml configuration file. 

This fixlet, being an example of the PowerShell usage, generates on-the-fly an XML file similar to NVidia's format, and then uses PowerShell to replace one of the attribute values in that file.

Property Details

StatusBeta - Preliminary testing ready for more
Title_template XML Editing Template Powershell
Source Release Date8/23/2018 12:00:00 AM
KeywordsXML, Powershell, Replace
Added by on 11/12/2018 10:45:08 AM
Last Modified by on 11/12/2018 10:45:08 AM
Counters 904 Views / 1 Download
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.


Used in 3 fixlets   * Results in a true/false
Show indented relevance
windows of operating system AND (if exists property "in proxy agent context" then not in proxy agent context else true)


Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
action uses wow64 redirection false

// build the powershell script that we will use to modify an XML file
createfile until EOF_EOF_EOF_EOF

This is a Powershell script to search an XML file for a given node, and replace an attribute value on any matching node(s)

$MyInvocation.ScriptName -file -xpath -name -value [-out ] [-showdetail]

powershell -ExecutionPolicy Bypass -File $MyInvocation.ScriptName -file "C:\temp\nv.xml" -xpath "//*[@uninstallReboot='true']" -name uninstallReboot -value false -out "c:\temp\nv-output.xml" -showdetail

Originally written to change brain-dead NVidia driver uninstallers to not force a reboot without warning on uninstall. The NVidia XML config files needed to be updated to remove the forced reboot.


param (
if ($showdetail) {{
    write-host "Parameters:"
    write-host "file: $file"
    write-host "Selection Search: $select"
    write-host "Node to change: $name"
    write-host "New value to set: $value"
    write-host "Output File: $out"
[xml]$xml=(Get-Content $file)
[System.Xml.XmlElement] $root = $xml.get_DocumentElement()
foreach ($node in $nodes) {{
if ($showdetail) {{ write-host "Found node " $node.OuterXml }
if ($showdetail) {{ write-host "Saving output to " $out }

delete updatexml.ps1
move __createfile updatexml.ps1

// Create a sample XML file to update, will change "uninstallReboot" to "false"
delete __createfile
createfile until EOF_EOF_EOF_EOF
="1.0" encoding="UTF-8"?>
="Graphics Driver" disposition="critical" versionText="391.74" timestamp="2018-06-05T02:19:48.000" name="Display.Driver" version="391.74">

    ="0" fixedProgress="0" phase="installAllDrivers" action="uninstall" when="uninstall" uninstallReboot="false">
="C:\Program Files\NVIDIA Corporation\Installer2\Display.Driver.{{2F1420AC-B99E-4088-ACE3-ACD203A2B05E}\*.inf" />
="PCI\VEN_10DE" />

delete sample.xml
move __createfile sample.xml

// Now, use powershell to modify an attribute within the sample file and output it to a new XML
waithidden powershell.exe -ExecutionPolicy Bypass -File updatexml.ps1 -file sample.xml -xpath "//*[@uninstallReboot='true']" -name uninstallReboot -value false -out sample-output.xml
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Social Media:
Share this page on Yammer


Log In or Register to leave comments!
JasonWalker -
BigFix.me does not display the embedded XML correctly, but downloading the .BES file does give the correct content; don't copy/paste the action script from the website display.