This One Time in a PowerShell Session…Part 3 of 31: Where Did All the Good Cmdlets Go?

imageIn the last post I talked briefly on how to read PowerShell, now lets take a look at how to find out what can you really do with PowerShell.  To start let’s take a look at all cmdlets you can do in your current PowerShell session.  In a PowerShell session run this simple cmdlet::


This will show a list of all the cmdlets currently loaded in your PowerShell session.  Some of them may surprise you (like dir) and we will talk about those in future post on aliases.  As you can see there are quite a few cmdlets and as we go through this month I will highlight some of the ones I use on a regular basis.  Before we starting digging into the cmdlets you first need to know that is not all the possible cmdlets you may at your fingertips.  The listing of cmdlets you get from Get-Command does not show you all of the cmdlets on your system only the currently loaded ones.  Based on what roles or other services you may have loaded on your system, PowerShell may have not loaded the corresponding cmdlets which support those particular services or functions.  You will need to not only learn if you have cmdlets available but also how to load them, so keep reading.  Also many software manufactures(outside of Microsoft applications) are even starting to include PowerShell cmdlets in their toolsets as well, and these cmdlets like the built-in ones from Microsoft will also need to be loaded to be used.  For example take a look at  the PowerShell support for Citrix, which  I learned from Carl (BTW thanks for the quick fixes on my typos): Finding Offline Citrix XenApp Servers Using Microsoft PowerShell Part 1 of 4

To see what cmdlets you maybe missing out on you need to know what modules you have available.  For now think of a module as a container for PowerShell cmdlets for a particular role or purpose.  To see the cmdlets available to you run the following cmdlet:Get-Module –ListAvailable

Get-Module –ListAvailable (you will something similar to the screen shot to the right)

The screenshot shows the modules I have on my Windows 7 Ultimate system.  When you run the same command on a Windows Server 2008 R2 you will see different modules.  The list of modules you see will also vary from server to server based on what roles and functions you have installed on the server.  As we go through this month of posts, you will see several of the Windows Server 2008 R2 modules and how they are used.  To temporarily load the cmdlets for a particular module you will need to use the Import-Module cmdlet.  When you import the module the cmdlets are temporarily loaded for your current PowerShell session.  When you close that session those cmdlets will go away, until you re-import the module.  In a future post I will talk about how to make PowerShell load the modules you want all the time using a concept called profiles. To load the AppLocker module you would run the following command:

Import-Module AppLocker

Now that you have loaded the modules let’s take a look at all the PowerShell goodies you just unlocked.  To see all of the cmdlets you could just use Get-Command, however this would show you all the cmdlets including the newly loaded ones.  So here is a little trick for  you.  You  can use the –Module parameter with the Get-Command cmdlet.  To see just the cmdlets for a particular module your command would look like this one I use for AppLocker (simply replace the module name for what you are looking for)

Get-Command –Module AppLocker

You might be thinking “Great  I see hundreds of commands that I know nothing about, now what?!?!”. First off do not be scared and do not run away! In tomorrows post I will show to get help, and begin the task of utilizing PowerShell!

Thanks for reading!  Remember if there is a topic on PowerShell you are curious about and would like Sarah or myself to cover in these postings, all you need to do is ask. Email either of us with your comments or suggestions, we look forward to hearing from you. Have a great day!

Comments (0)

Skip to main content