PowerShell: Printing Version and Inline Help

, , …,

PowerShell is bundled with Windows 7 (released in 2009). If your Windows does not come with PowerShell, you can download PowerShell at Source technet.microsoft.com. Make sure you are downloading PowerShell version 2 or later.

To start PowerShell, press 【❖ Win+r】 then type powershell. (Better to use PowerShell ISE (Integrated Scripting Editor). Type powershell_ise.)

Show PowerShell Version

To find out your PowerShell version, type $PSVersionTable in PowerShell. For example, here's my output:

PS C:\Users\h3> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5446
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

Note: PowerShell executable's folder path c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe may say “v1.0”, but that is not the real version number.

Command Line Help

PowerShell has extensive built-in help system. Just type “help” and read thru it.

#Some common help forms:

help dir             # display a short doc for “dir”
help dir -examples   # show examples of using “dir”
help dir -full       # display the complete doc, including examples

help *r              # display all commands ending in r
help help            # display doc for help itself

Take some time to get familiar with help, its content structure, formats, because you will be using it a lot.

There is also a GUI based help file. In powershell_ise, just pull 〖Help〗 menu.

Tab for Name Completion

PowerShell supports name completion, by the Tab ↹ key. So, you can press the tab key and it will complete your typings. Press tab again to see the next choice.

The name completion can be applied to options as well. For example, type help dir -e then Tab ↹.

blog comments powered by Disqus
2009-07