Slides used to accompany the demos in a 4 hour follow along workshop given for the SteelCon event in Sheffield on Friday 11th July 2025
https://www.steelcon.info/
ago!) EUC focus since 1995 PowerShell since 2014 (C, C++, C# previously as well as vbs, cmd, kix, *nix shell) Mostly write PowerShell for software vendors like ControlUp, Parallels, Flexxible & more Invented & wrote Ivanti Application Control (was AppSense Application Manager) Microsoft MVP in PowerShell category (5 6 years) Available Services – code reviews, support ,performance improvements, training, workshops, code security analysis @guyrleech
• Get-Command • Get-Member (gm) or pipe object to Select * or Format-List (fl) * • Ctrl r (but beware persistent history and Windows Terminal history) • (Ctrl) home/end/backspace/delete/arrows • Ctrl z • Comments (# and <# #>) • Aliases (but not in scripts) • Out-GridView (ogv (broken in pwsh 7.5.*))/ ConvertTo-Json
attributes like datestamps ? • Get-ChildItem (alias dir & ls) • -Filter (more efficient) versus –Include (array) • -Exclude • Select-String (sls) (*grep) • Default search parameter is –Pattern which is a regex (no screams please) • Matches are objects • -Context
into sortable/filterable objects (pipe to Out-GridView (ogv) or csv) • Build and test as you go • If it’s delimited, use Import-Csv/ConvertFrom-Csv instead • $Matches • Matching groups (can be named) • [^]+ (not any of the following)
far left as you can (-Filter , -Attributes, -File) • Typical properties used are Length, LastWriteTime, CreationTime • Where-Object (with –and or –or) • Can search on VersionInfo and permissions/owner (Get-Acl)
software & hardware vendors tend to add their own • Remotable • Information gathering but not everything is passive, eg win32_userprofile • Do not use win32_product (not passive – use the registry)
registry key & values • Favourite in regedit & rename for debugging • HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription • EnableTranscripting, EnableInvocationHeader, OutputDirectory • Random logfile name in date subfolder (all auto created) • Who has read access? • Automation to delete/archive old log files, especially if have software/agents that run PowerShell frequently • Can cause scripts to lose output