Cheatsheets

Do it with the command line

You’ve built a Windows server without the GUI (Server Core only). You’re thinking, I use the command line all the time, this will be easy. It won’t. This cheat sheet has a few useful bits and pieces on how to configure it. #Force Windows Updates (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() #Dump the network interface config (to edit it) netsh interface dump > netcfg.dat #edit the config notepad netcfg.dat #Restore the interface config netsh exec netcfg.

Powershell Regex cheat sheet

A collection of regex’s that I always find myself looking up. #Match while tagging match groups 'CowColour Brown' -match '(?<Attribute>\w+) (?<Value>\w+)' | out-null $matches.Attribute $matches.Value #cowColour #Brown #Matching groups - your $matches object will have properties containing the valid matches "Subnet:10.1.1.0/24" -match 'Subnet:(?<SiteSubnet>(?:\d{1,3}\.){3}\d{1,3}/\d+)' #Replace to reformat a string 'This is a wild test' -replace '.*(w[^ ]+).*','Not so $1' #Not so wild #Lazy matching (to prevent over-matching) use a ? after the + or * "<h1>MyHeading</h1>" -replace '<([^/]+?