Simple tip for PowerShell

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.

Explore posts in the same categories: PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: