You remember how neat it was when you learned you could serialize .NET DataTables to xml files? Well, I do. Now you could create simplest-case tests for your controller logic against "real" data about as complex as you wanted, but without having to worry about your database's shifting state -- or even having a database installed on a workstation. Now you could send a limited set of clean data to a contractor and *know* (essentially) that what you got back was going to be pretty much plug and play. It was wonderful.

Well, TIL... You can do just as cool (probably cooler) a set of stuff with Powershell.

From often Googled "Hey, Scripting Guy!"

If I need to shut down Windows PowerShell or to reboot my computer, how can I continue to access the same process objects? I use the Export-Clixml cmdlet.
..
The command itself is simplicity and elegance personified. To obtain all the process information, I use the Get-Process cmdlet (gps is an alias), and I pipe the results to the Export-Clixml cmdlet. I provide the Export-Clixml cmdlet with a path to store the resultant XML file. This command is shown here:

gps | Export-Clixml c:\fso\gps.xml

The resultant XML file is an actual XML file and is therefore viewable in an XML viewer...

To import the XML for use on my computer, I use the Import-CliXML cmdlet. It only needs the path to the XML file. I can store the resultant process objects in a variable for ease of processing.

Man, that's easy.

$myObject | Export-CliXML MyObject.xml

... years later ;^) ...

$myObject = Import-CliXML MyObject.xml

You lose some functions, etc, if your object had them, but hello, quick state restore. Beautiful.

Labels: ,