PowerShell Cheat Sheet, Punctuation Edition

I've posted before about some of PowerShell's sometimes-maddening punctuation - parentheses, braces, and brackets, oh my! This time, I've decided to do something more substantial about it: Make a cheat sheet. Only I actually need your help to make sure I've gotten all the little bits of punctuation, and their various uses, covered - including usage in both the help file syntax as well as on the actual command-line. If you'd like, download the draft athttp://files.concentratedtech.com/pilot.pdf, and look it over. It's only a couple pages long, and if you find an error or something missing, drop a comment here on the blog.

What other stuff would you put in a PowerShell cheat sheet? What are you continually having to look up and remind yourself of?

Discuss this Blog Entry 9

on Dec 29, 2010
Link now gone. http://files.concentratedtech.com/pilot.pdf
Also noticed the link on pg. 7 on another poster for 'Power of Powershell' is also dead. Issue 11.

Must be the holidaze?


Nick (not verified)
on Sep 27, 2010
Nice, I like the direction this going. A couple things..

? is an alias for where-object, not select-object

A double colon can be used with something like, [datetime]::now







Robert (not verified)
on Sep 24, 2010
Good idea!
Here are a few you missed:
: - precedes the name of a label
, - Comma Operator - wraps the token that follows it in an array, e.g. ,$a
.. - Range Operator
$() - Subexpression
% - also, Modulus Operator
! - Alias for -not Negation Operator
~ - Alias for $env:USERPROFILE through Tab completion only







Snusmumriken (not verified)
on Sep 24, 2010
A good summary of all those squibbly characters that can be so hard to separate. Although I'd move the more uncommon uses to a footnote or something, to simplify reading and keep clarity. I'm mainly thinking of
- "┬┤$ (dollar sign): ... This can be tricky when working with the cmdlets that..."
- The third note on @-character.

And (now I'm being picky), a here-string can use single quotation marks as well (@' '@). It isn't quite obvious when you write like you do there.







Mike (not verified)
on Sep 24, 2010
I believe 'grave accent' is the proper name for character you are calling backtick.



Shawn Melton (not verified)
on Sep 24, 2010
Adding in the comparisons would be good for me. I always seem to forget them, of course if I used them more often it would probably help me remember them :)

I am refering to the -eq, -ne, -gt, -contains, -like, etc.

Wallen (not verified)
on Sep 24, 2010
A very ehlpful cheat sheet. I'd like to see one regarding excuting commands through winrm (Non-interective).... invoke-command with msiexec and uninstalling a guid with curly braces... or invoke-command with weird command-line arguments ...fun stuff. (Some is covered in your faq... but were talking cheat sheet here).

The only suggestion I have for this cheat sheet is separate the quotes in those seactions. Two single quotes '' in the PDF looks like double quotes (Which confused the heck out of me at first). So, maybe it should be ' ' in the single questes section and " " in the double quotes section.

Makovec (not verified)
on Sep 24, 2010
Hi Don,
nice one. Just few comments

.(period) - also can be used for dot-sourcing, maybe small comment can help.

Small typo in 28.2 first bullet point:
is: [square brackets[
I believe it should be: [square brackets]

David








Andy (not verified)
on Sep 23, 2010
CD ~ to return to Home directory and
<# ... #> to Block comment
Perhaps ?
Regards
A.



Please or Register to post comments.

What's PowerShell with a Purpose Blog?

Don Jones demystifies Windows PowerShell.

Blog Archive

Sponsored Introduction Continue on to (or wait seconds) ×