Cheat Sheet: PowerShell

Series of short snippets of FUC. This one is for PowerShell.
March 6, 2019
powershell

A few snippets of PowerShell I’ve found useful over and over again. Most of them are just syntax/functions that I’m unable to remember, some of them might be more complex.

It’s a living document, I keep updating it.

XML parsing

$xmlDoc = [XML](Get-Content $filePath)
$xmlDoc.Element.Subelement.setAttribute("Attr", $value);
$xmlDoc.Save($filePath)

JSON parsing

$jsonDoc = Get-Content $filePath | Out-String | ConvertFrom-Json
comments powered by Disqus