Been doing more in PowerShell every week and while I’m far from being an expert I definitely enjoy what it offers. I’m always looking for tips and tricks to get the most out of PoSh and one came in my inbox today.
A short article by Jeffery Hicks pointed out something simple that makes perfect sense. Color coding the output to distinguish between your function info and the actual output.
Function Do-Something { #run some code here Write-host "Starting update process" -foregroundcolor Green $procs=Get-wmiobject win32_process Write $procs }
When his above sample is run, the function message shows in green and the sorted and filtered output is sent to the pipeline.
Have to remember this for re-doing some of the early scripts I setup to see if I can clean them up.