PowerShell will happily provide a list of all registered cmdlets using Get-Command. Here's a partial list:
CommandType Name Definition ----------- ---- ---------- Cmdlet Add-Content Add-Content [-Path] <String[]> [-Value] <Ob... Cmdlet Add-History Add-History [[-InputObject] <PSObject[]>] [... Cmdlet Add-Member Add-Member [-MemberType] <PSMemberTypes> [-... Cmdlet Add-PSSnapin Add-PSSnapin [-Name] <String[]> [-PassThru]... Cmdlet Clear-Content Clear-Content [-Path] <String[]> [-Filter <... Cmdlet Clear-Item Clear-Item [-Path] <String[]> [- Force] [-Fi... Cmdlet Clear-ItemProperty Clear-ItemProperty [-Path] <String[]> [-Nam... Cmdlet Clear-Variable Clear-Variable [-Name] <String[]> [-Include... Cmdlet Compare-Object Compare-Object [- ReferenceObject] <PSObject... Cmdlet ConvertFrom-SecureString ConvertFrom-SecureString [- SecureString] <... Cmdlet Convert-Path Convert-Path [-Path] <String[]> [-Verbose]...
In Chapter 9, we'll talk you through output formatting, which helps prevent information from getting lost "off the edge" of PowerShell's 80-column display window.
Using Get-Command is a good way to inventory what your capabilities within PowerShell are. For any given cmdlet, Get-Command tells you more about it. For example, the following example describes what the Set-Alias cmdlet does:
PS C:\>Get-Command Set-Alias
The following example produces a lengthy description of the Set-Alias cmdlet, along with details about each argument, examples of how the cmdlet is used, and so forth.
PS C:\>Get-Help Set-Alias
Tip | Try using Help instead of Get-Help; Help isn't an alias, but rather a built-in function. It calls Get-Help and display the output one page at a time, making it easier to read lengthy entries. |
Get-Help can also be used to help discover new cmdlets. For example, if you want to create a new service, but aren't sure what the proper cmdlet would be, Get-Help can help you find out:
PS C:\>Get-Help *Service
The * wildcard tells Get-Help to display a list of help topics related to services; since there's a help topic for each cmdlet, you'll also be looking at a list of cmdlets related to services.
Many cmdlets can accept parameters that are passed by name using a hyphen, then the parameter (or argument) name followed by a space, and then the value you're passing to the parameter. The following example creates a new file.
PS C:\>New_Item -type file "myfile.txt"
Notice the -type parameter, which is given the values file and a filename. When parameters are passed by name, they can be passed in any order. Some parameter names may be abbreviated such as -db for -debug. Valid abbreviations are always listed in the command's help.
Most cmdlets support a set of ubiquitous parameters, which are always optional. This means ubiquitous parameters such as those listed below don't need to be specified if you don't want to use them.
-Debug (-db). Instructs the cmdlet to provide additional programmer-level detail about the operation.
-ErrorAction (-ea). Controls the behavior of the cmdlet when an error occurs. Values can be NotifyContinue (which is the default), NotifyStop, SilentContinue, SilentStop, and Inquire.
-ErrorVariable (-ev). Specifies the name of a variable that will store all objects that encountered an error while processing. The specified variable is processed in addition to the built-in $ERROR variable.
-OutVariable (-ov). Specified the name of a variable in which to place all objects that are output from the cmdlet.
-Verbose (-vb). Instructs the cmdlet to produce additional output about its actions and progress.