header image

Scripting Games 2012 Comments: #1 Line Continuation

Posted by: | April 8, 2012 | 1 Comment |

As with previous games I’ll publish a series of comments on the games. I won’t deal with any event specific issues until the games events are all closed but there are some things coming through that while not affecting any gradings don’t make the best use of PowerShell.

The first one that’s jumped out is line continuation.

I’ve seen a number of examples like the following two

get-service | `
sort status  -Descending


get-service  `
| sort status  -Descending

Both work but the line continuation character is unnecessary

All you need to do is

get-service |
sort status  -Descending

The pipeline symbol also works as a line continuation.

A minor point maybe but let PowerShell do the work for you

under: PowerShell Basics, Scripting Games

1 Comment

  1. By: Jaap Brasser on April 11, 2012 at 1:30 am      

    Excellent, I actually made this mistake in my scripts, thanks for the update!