Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PowerShell keywords

44 views
Skip to first unread message

Larry__Weiss

unread,
Feb 7, 2010, 1:50:35 PM2/7/10
to
exit as processed at a PowerShell prompt does not show up as an Alias, nor is it
a Function.

get-help exit
pulls up help on the Exit-PSSession cmdlet

get-help Exit-PSSession -full
gets me this hint
"The Exit keyword has the same effect as using Exit-PSSession."
(Which by the way I don't find to be true in general.)

Now that I know exit is a keyword I can use
get-help keywords -full
to get better documentation on exit as a keyword, and find all the other
PowerShell keywords.

I'm still hoping someday to find a formal definitive PowerShell language
reference published by Microsoft.

- Larry

Martin Zugec

unread,
Feb 8, 2010, 7:02:51 AM2/8/10
to

Wiki would be ideal :(

Martin

"Larry__Weiss" <l...@airmail.net> wrote in message
news:uYzqyZCq...@TK2MSFTNGP06.phx.gbl...

RichS [MVP]

unread,
Feb 8, 2010, 5:59:01 PM2/8/10
to
don't forget to check get-help about_reserved_words as well
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Larry__Weiss" wrote:

> .
>

Larry__Weiss

unread,
Feb 8, 2010, 7:39:05 PM2/8/10
to
How many classifications of "words" are there in PowerShell?

Here are the lists I get from

get-help about_reserved_words -full

TOPIC
about_Reserved_Words
SHORT DESCRIPTION
Lists the reserved words that cannot be used as identifiers because they
have a special meaning in Windows PowerShell.

Reserved words (both a reserved word and a keyword unless indicated otherwise)
Break
Continue
Do
Else
Elseif
Filter
For
Foreach
Function
If
In
Local <-- not a keyword
Private <-- not a keyword
Return
Switch
Until
Where <-- not a keyword
While

==============================================

get-help about_language_keywords -full

TOPIC
about_Language_Keywords
SHORT DESCRIPTION
Describes the keywords in the Windows PowerShell scripting language.

Keywords (both a reserved word and a keyword unless indicated otherwise)
Begin <-- not a reserved word
Break
Catch <-- not a reserved word
Continue
Data <-- not a reserved word
Do
Dynamicparam <-- not a reserved word
Else
Elseif
End <-- not a reserved word
Exit <-- not a reserved word
Filter <-- not a reserved word
Finally <-- not a reserved word
For
Foreach
From <-- not a reserved word
Function
If
In
Param <-- not a reserved word
Process <-- not a reserved word
Return
Switch
Throw <-- not a reserved word
Trap <-- not a reserved word
Try <-- not a reserved word
Until
While

I'm starting to get confused by the three categories so far
Reserved word only
Keyword only
Both a reserved word and also a keyword

And what is the meaning of "identifier" in the short description returned by
get-help about_reserved_words -full
?
Bruce Payette's book "PowerShell in Action" does not use "identifier" in a way
that I can match up with
"...the reserved words that cannot be used as identifiers..."

- Larry

RichS [MVP]

unread,
Feb 10, 2010, 3:45:01 PM2/10/10
to
where is an alias of where-object which is why it is included

An identifer is taken to be the name of something - often a variable name.
It means that the reserved words can't be used as the names for variables or
functions etc

--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Larry__Weiss" wrote:

> .
>

Larry__Weiss

unread,
Feb 10, 2010, 4:11:33 PM2/10/10
to
I thought that variables had their own namespace.

For example I can code

PS C:> $if = 1
PS C:> if ($if -eq 1) {$if}
1
PS C:> dir variable:if
Name Value
---- -----
if 1
PS C:>

0 new messages