Monthly Archive

Categories

Scripting Games Comments IV

This one doesn’t affect the way PowerShell runs it is just unnecessary typing.

You don’t need to put a semi-colon at the end of each line

$proc = Get-Process;
$proc | where {$_.Name -like "s*"};

PowerShell is more than happy for this

$proc = Get-Process
$proc | where {$_.Name -like "s*"}

The only time I would use a semi-colon is if I wanted to have multiple commands on the same line

$proc = Get-Process; $proc | where {$_.Name -like "s*"}

In this case the semi colon functions as an end of line (command) marker.

Using ; at the end of each line will work but its extra typing you don’t need.

Leave a Reply