Share via


Editing XML using PowerShell

I recently had a requirement to edit an XML document using PowerShell  Fortunately, this is a relatively easy task as shown below.  I’ve used a system environment variable %USERPROFILE% to populate the path to the file.

The script modifies a value in the XML document (highlighted in the example below) and ensures this is persisted using the .Save method.  The intention is to execute this script during user logon to ensure the value is always disabled in the application, ProClarity Web Professional 6.3 SP3.

clip_image002

REM Code changes CheckQuerySize=”Yes” to CheckQuerySize=”No”

REM Windows XP
$xmlFile = “$env:userprofile\Application Data\ProClarity\Client\Options.xml”
$xmlDoc = [XML](gc $xmlFile)
$xmldoc.ProClarity5Options.ProClarityApp.CheckQuerySize = "No"
$xmldoc.Save($xmlFile)

REM Windows Vista and Windows 7
$xmlFile = “$env:userprofile\AppData\Roaming\ProClarity\Client\Options.xml”
$xmlDoc = [XML](gc $xmlFile)
$xmldoc.ProClarity5Options.ProClarityApp.CheckQuerySize = "No"
$xmldoc.Save($xmlFile)

Comments

  • Anonymous
    December 04, 2013
    Thanks a Ton.