July 4th, 2014

PowerTip: Difference Between XML PowerShell Cmdlets

Doctor Scripto
Scripter

Summary: Understand the difference between XML cmdlets in Windows PowerShell.

Hey, Scripting Guy! Question What is the difference between the Windows PowerShell cmdlets, Export-CliXML and ConvertTo-XML?

Hey, Scripting Guy! Answer The Help file for ConvertTo-XML says:

“This cmdlet is similar to Export-CliXML, except that Export-CliXML stores the resulting XML in a file.
ConvertTo-XML returns the XML, so you can continue to process it in Windows PowerShell.”

The Export verb encapsulates your objects in a persistent data store (such as a file) or into an
interchange format. The ConvertTo verb simply changes the objects in the pipeline for continued use.
If you follow ConvertTo-XML with Out-File, you would get similar results to Export-CliXML.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.