Saving Data as an XML File From PowerShell
The Export-CliXml cmdlet can be use to save Windows PowerShell output in XML format. For example following simple command uses the Get-Process cmdlet to retrieve information about all the processes running on the computer. That information is then piped to the Export-Clixml cmdlet, which in turn saves the data as an XML file named C:\Scripts\Test.xml:


Code:

Get-Process | Export-Clixml c:\scripts\test.xml



Saving Data as an XML File From PowerShell DmLHT3z


By default Export-Clixml overwrites any existing copy of C:\Scripts\Test.xml. If you’d prefer not to overwrite Test.xml then simply include the -noclobber parameter in your command:


Code:

Get-Process | Export-Clixml c:\scripts\test.xml -noclobber


If you run this command and Test.xml already exists you’ll get back the following error message:

Export-Clixml : File C:\scripts\test.xml already exists and NoClobber was specified.