Automation · PowerShell Automation
XML
Cheat sheet · https://pcornel.dk/topic.php?topic=5252
Answer
PowerShell handles XML with [xml] type casting, Select-Xml with XPath, and Export-Clixml and Import-Clixml for saving objects, including encrypted credentials for the same user.
Remember
- [xml] casts text to an XML document.
- Select-Xml queries with XPath.
- Export-Clixml saves objects with types.
First checks
[xml]$x = Get-Content f.xml— parseSelect-Xml -Path f.xml -XPath '//node'— XPath$x.Save('out.xml')— write
Verify in this order
XML file → [xml] → XPath/edit → save
Where it usually breaks
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
XML · PowerShell operational reference
| Boundary | XML reference |
|---|---|
| Runtime identity | PowerShell edition/version + command/module source |
| Persistent intent | Script/module/config prerequisites under source control |
| Verification | Read-only discovery → execution evidence → independent target read-back |
| Output contract | Structured objects/streams before formatting |
| Failure boundary | Separate engine/binding from transport/API/native and target-state failures |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5252