Welcome back! Today we’re learning about PowerShell Cmdlets and PowerShell Providers.
If you missed the first part of this short series, make sure to take a look at it when you get a chance.
Take Command of Server 2008 with Windows PowerShell - Part 1 will provide you with a good introduction to PowerShell and show you the steps to installing and accessing PowerShell on your Server 2008.
Now let’s get started with Cmdlets, the essence of Windows PowerShell.

Taking advantage of the power of PowerShell is done with the use of cmdlets. The cmdlets are powered by a set of .NET objects and methods developed with server and network administrative purposes in mind.
An example of a cmdlet is Get-ChildItem, which is used for listing the contents of an object. That’s right, object.
Any output created within PowerShell is output in the form of an object as opposed to text. An object is an item that can contain multiple properties and/or methods, which can return more objects.
If no action is performed on an object, PowerShell outputs the object details in text form. Actions can be performed on an object returned by a cmdlet by pipelining another command with the pipe character between commands.
The command below lists the contents of the current object (directory) sorted by name in descending order.
get-childitem | sort-object “Name” –descending
In the above example, the Sort-Object cmdlet is used on the return object of the Get-ChildItem cmdlet to sort by the Name property. Tacked onto the end of the command are the property and descending parameters.
The actions performed by cmdlets are determined by the parameters supplied to the cmdlet. Alternatively you could have supplied the –property parameter flag before “Name”, but because that is the cmdlet’s default parameter, that is not necessary.
Aside from the cmdlet specific parameters, you can also use common parameters with cmdlets to be handled by the PowerShell engine itself.
Not all cmdlets support all the common parameters; most of them usually work though. The common PowerShell parameters are defined below:
-confirm – Prompts the user for confirmation before executing a command.-debug – Tells the cmdlet to provide debugging information.-ErrorAction – Allows the cmdlet to; continue, stop, silently continue or inquire when an error occurs.-ErrorVariable – Tells the cmdlet to assign error information to the variable specified.-OutBuffer – Tells the cmdlet to hold a certain number of objects before calling a pipelined cmdlet.-OutVariable – Tells the cmdlet to assign output to the variable specified.-verbose – Tells the cmdlet to provide more detail.-whatif – Tells the result of executing the command without executing it.If you have been working along, you probably noticed that the output from the Get-ChildItem cmdlet looks a lot like what you would expect to see by entering dir. This is no coincidence.
When you enter dir you are actually entering the alias assigned to the Get-ChildItem cmdlet. Cmdlets come with pre-assigned aliases and can also have custom defined aliases.
Cmdlet aliases can be listed with the Get-Alias and set with the Set-Alias cmdlets.
Should you ever have the need to find out more information on a cmdlet you can use the Get-Help cmdlet. The Get-Help cmdlet itself has parameters such as –detailed and –full for determining the amount of help shown.
If you ever have trouble remembering the name of a cmdlet you can use the Get-Command cmdlet. Entering Get-Command by itself lists all the PowerShell cmdlets. You can also supply part of a cmdlet name to narrow down the results like in the example below:
get-command get-
Executing the above command lists all the cmdlets that begin with ‘get-‘. The Get-Help and Get-Command cmdlets should prove very useful for helping you to get familiar with the capabilities and usage of PowerShell.
By default, when PowerShell is launched, you will start with your profile folder as your working directory. Access to this directory is available to you courtesy of the FileSystem provider.
PowerShell providers take the form of logical drives that provide access to data stored within the drives in a fashion that can be navigated and manipulated using the PowerShell cmdlets.
PowerShell comes packaged with seven default providers. You can list the available providers and their respective drives with the Get-PSProvider cmdlet. Additional providers can be installed with the New-PSDrive cmdlet.
The default PowerShell providers are explained below:
You can gain access to the different PowerShell providers by using the Set-Location cmdlet. The command below will change the working directory to the Variable provider.
set-location variable:
From the Variable provider you can list all the variables assigned in the console and their respective values with the Get-ChildItem cmdlet. You can also create new variables using the New-Item cmdlet or remove them with the Remove-Item cmdlet amongst other things.
It’s important to note that the Variable provider is not the only place you can work with variables. Variables can be assigned or used anywhere you go with PowerShell.
Variables are identified in the PowerShell console with the dollar sign. Executing the command below will assign a value to a variable.
$variable = “I’m a variable”
To display the newly assigned variable, execute the command below.
$variable
Providers give great potential for expanding the capabilities of PowerShell. They provide access for working with many resources on the server.
The PowerShell provider system has removed the restriction of working solely with the server’s file system within the command shell environment.
We’re done for today, but don’t forget to come back next week for more on taking command of Server 2008 with Windows PowerShell!
Chris Haaker Says:
March 3rd, 2008 at 8:45 am
I love the articles. However, when I run your examples I often get errors, as I did here when trying to run the get-command get- :
Get-Command : The term ‘get-’ is not recognized as a cmdlet, function, operable program, or script file
m and try again.
At line:1 char:12
+ get-command
Jason Ensinger Says:
March 5th, 2008 at 12:31 am
Hello Chris,
I tested the command you pointed out and was able to produce the same results. I wrote these articles several months ago so I am not sure if there has been a change to the behavior of the Get-Command cmdlet has changed or more likely, I didn’t test the command well enough.
To find the problem with the usage in the example I ran the command below.
get-help get-command -full
As it turns out, the default parameter for the cmdlet is the -name parameter which is meant to take the full cmdlet, function, program or script name. The functionality of narrowing down the results returned by the Get-Command cmdlet is available via the -verb and -noun parameters which are used to search the left and right of the hyphen in the cmdlet respectively.
In order to see the functionality intended by the erroneous, get-command get-, example in the article use the command below.
get-command -verb get
Notice I didn’t include the hyphen after the get in the command above. This is because the hyphen is used to seperate the verb and noun in the command therefore including it in the search returns no results. The command below is an example of using the -noun parameter to search the right side of the hyphen in the cmdlets names.
get-command -noun item
Thanks for pointing out the error Chris. I hope this clarifies everything.