Cmdlets and Add-ons

This is the time of year when many people go out looking for a gift for that special someone in their life. Well, needless to say, nothing says “I love you” quite like a selection of new cmdlets and new PowerShell add-ons.

Well, OK. But new cmdlets and new PowerShell add-ons still make for a pretty nice gift.

On This Page

Quest Cmdlets for Active Directory NetCmdlets GPMC PowerShell Cmdlets PowerGadgets PowerShell Community Extensions Extensions for Windows PowerShell PowerTab

Quest Cmdlets for Active Directory

Why would cmdlets make such a nice gift? Well, for one thing, these aren’t just any cmdlets. For example, take the Active Directory cmdlets (free download) created by Quest Software. If you work with Active Directory (and these days pretty much everyone works with Active Directory) then you owe it to yourself to grab a copy of Quest’s Active Directory cmdlets.

Why? Well, to be brutally honest, trying to manage Active Directory using Windows PowerShell might not be the most enjoyable experience you’ll ever have. That’s because PowerShell doesn’t ship with an Active Directory provider or with any Active Directory cmdlets; consequently, you’re stuck using an odd mixture of ADSI coding and .NET Framework classes in order to work with Active Directory. Can it be done? Sure. Can you have a tooth pulled without using any sort of anesthetic? Sure. If you catch our drift.

That’s not the case with the Active Directory cmdlets, cmdlets that make Active Directory management as easy as, well, pulling teeth. How easy is that? Well, if we wanted to, we could sit here all day and show you example after example that demonstrates how easy it is to manage Active Directory using the Quest cmdlets. As tempting as that might be, however, we’ll limit ourselves to a few telling examples.

Like what? Well, if you’ve worked with Active Directory then you know how difficult it can be to do something as seemingly-simple as binding to a user account; that’s because Active Directory requires you to specify the user’s ADsPath when connecting to his or her account:

LDAP://CN=Ken Myer,OU=Finance,dc=fabrikam,dc=com

That can be a problem. (Well, unless you’ve memorized the ADsPaths for all your users.)

So how do the Active Directory cmdlets help? Here’s one way: they enable you to bind to a user account using just the user’s logon name:

Get-QADUser kmyer

Alternatively, you can bind to the user account using the user’s domain and user name:

Get-QADUser "fabrikam\kmyer"

Need to disable Ken Myer’s user account? This simple command will do the trick:

Disable-QADUser "fabrikam\kmyer"

Need a list of all your domain controllers? Sure; why not:

Get-QADComputer -computerRole "DomainController"

How about a list of all your users who work in the Finance department:

Get-QADuser -searchroot 'fabrikam.com/UserAccounts' -ldapfilter '(department=Finance)'

And yes, that’s an actual Active Directory search carried out using a single line of code. Now do you see why we’re so excited about these cmdlets?

Here’s something else to keep in mind: not only are the Active Directory cmdlets free, but these babies are also accompanied by a 136-page manual that describes each cmdlet in detail. (And shows you plenty of examples, to boot.)

In other words, why are you wasting your time reading this article? Shouldn’t you be downloading the Active Directory cmdlets from Quest?

NetCmdlets

On the other hand, if you stop reading you’ll never hear about the NetCmdlets networking cmdlets available from /n software. (Free to try for 45 days; prices vary after that, starting at $99 for a single workstation license.) The NetCmdlets provide access to a boatload of different networking protocols, including SNMP, LDAP, DNS, HTTP, FTP, SMTP, POP, IMAP, Telnet, and more. Want to send an SMTP or POP email using Windows PowerShell? NetCmdlets makes that easy. Want to monitor and manage a DNS server using Windows PowerShell? NetCmdlets make that easy. Need to ping a computer using Windows PowerShell? With NetCmdlets, that’s as easy as running this command:

Send-Ping -server atl-dc-001

Here’s a little holiday bonus for you: you can also create .ZIP files using NetCmdlets. For example, the following command grabs all the files in the folder C:\Scripts and adds them to a .ZIP file named C:\Test\Scripts.zip:

Write-Zip -Input C:\Scripts\* -Output C:\Test\Scripts.zip

Ho, ho, ho indeed!

GPMC PowerShell Cmdlets

Did someone say, “Group Policy cmdlets?” Oh. Well, that’s too bad. Someone should have said “Group Policy cmdlets,” because SDM Software’s GPMC PowerShell Cmdlets 1.0 (free download) includes a very cool set of cmdlets that enable you to perform Group Policy management tasks like: creating and deleting GPOs; linking GPOs to sites, domains and OUs; modifying GPO security; and, last but surely not least, backing up and restoring GPOs. (Note that you must have GPMC, the Group Management Policy Console, installed in order to use these cmdlets.) Are these cmdlets really all that useful? Well, that depends; how useful would you find it to disable the Computers portion of a GPO using one line of code:

$x = Get-SDMGPO "Test GPO"; $x.SetComputerEnabled(0)

Or maybe you’d like to backup that GPO using these two lines of code:

$x = Get-SDMGPO "Test GPO"
$x.Backup("C:\Test","Test GPO Backup - December 2007")

See what we mean?

PowerGadgets

No holiday (with the possible exception of Arbor Day) would be complete without a copy of PowerGadgets. (Free to try for 60 days; prices vary after that, starting at $299 for a single workstation license.) If you’ve worked with Windows PowerShell then you’re familiar with commands like this one, a command that uses WMI’s “cooked” performance counters to return the total amount of free disk space on a computer:

get-wmiobject win32_perfformatteddata_perfdisk_logicaldisk |
select-object name,percentfreespace |
where-object {$_.Name -eq "_Total"}

No doubt you’re also familiar with the kind of output this command produces:

name                                       percentfreespace
----                                       ----------------
_Total                                                   57

But, then again, it’s Windows PowerShell; it’s not like you can produce output similar to this:

Or even this:

Well, not unless you use PowerGadgets, that is.

PowerGadgets provide an incredibly simple way to display PowerShell output in graphical format (as a dial, a gauge, a chart, even a map.) How simple is “incredibly simple?” Well, consider this PowerShell script that returns the total amount of free disk space on a computer:

Get-WMIObject Win32_PerfFormattedData_PerfDisk_LogicalDisk |
Select-Object Name, PercentFreeSpace |
Where-Object {$_.Name -eq "_Total"}

How do we display the returned data as a gauge? Simply by piping that data to the Out-Gauge cmdlet:

Get-WMIObject Win32_PerfFormattedData_PerfDisk_LogicalDisk |
Select-Object Name, PercentFreeSpace |
Where-Object {$_.Name -eq "_Total"} |
Out-Gauge

Cool.

Note. For more information on using PowerGadgets, take a look at the webcast Amazing But True, part of the Scripting Guys Windows PowerShell Week.

PowerShell Community Extensions

Believe it or not, we’re not done yet; for one thing, we haven’t even mentioned the PowerShell Community Extensions.

OK, consider them mentioned. The PowerShell Community Extensions (free download) are a veritable grab-bag of PowerShell cmdlets, functions, filters, and providers, all written by members of the PowerShell community. To say that there’s something for everyone in here would be an understatement; for example, there are cmdlets that can return version information for a file and cmdlets that can modify the creation/last accessed date and time for a file or folder. There are cmdlets that can return information about DHCP servers and Active Directory domain controllers, and cmdlets that can create file system hardlinks. Among the Scripting Guy’s favorites are a set of cmdlets for working with the Clipboard. Want to assign the contents of the Clipboard to a variable? Then use a command similar to this:

$x = Get-Clipboard

Prefer to write something to the Clipboard yourself? Here’s one way to do that:

Write-Clipboard $x

Pretty cool, huh?

This is cool, too: when you install PowerShell Community Extensions an Open PowerShell Here command is added to the context menu in Windows Explorer:

No, really, that is cool. Now you can right click the icon in the upper left-hand corner of any Windows Explorer window, choose Open PowerShell Here, and open an instance of PowerShell set to that particular folder. Give it a try and you’ll see what we mean.

And let’s not forget the DirectoryServices provider included in the package. As we noted a while back, using Windows PowerShell to work with Active Directory is … interesting … to say the least. But that’s only true if you’re adverse to using third-party and community cmdlets. When you install the PowerShell Community Extensions you also install a DirectoryServices provider that enables you to access Active Directory in the exact same manner you access the file system. For example, suppose you’re a member of the Fabrikam domain. Want to take a look at the objects stored in the root of that domain? Then just issue this command:

Get-ChildItem fabrikam:

In return, you should see something similar to this:

LastWriteTime Type                 Name
         ------------- ----                 ----
    10/4/2007 11:41 AM builtinDomain        Builtin
    10/4/2007 11:58 AM container            Computers
    10/4/2007 11:42 AM organizationalUnit   Domain Controllers
    10/4/2007 11:41 AM container            ForeignSecurityPrincipals
    10/4/2007 11:54 AM organizationalUnit   Groups
    10/9/2007  3:27 PM infrastructureUpdate Infrastructure
    10/4/2007 12:05 PM organizationalUnit   InterForest Replicas
    10/4/2007 11:41 AM lostAndFound         LostAndFound
    10/4/2007 11:42 AM organizationalUnit   Machines
   10/25/2007  2:53 PM msExchSystemObjec... Microsoft Exchange System Objects
    10/4/2007 11:42 AM organizationalUnit   MSMQ Users
    10/4/2007  1:50 PM container            OperationsManager
    10/4/2007 11:42 AM container            Program Data
    10/4/2007 11:42 AM organizationalUnit   Resources
    10/4/2007 11:41 AM container            System
    10/4/2007 11:41 AM organizationalUnit   UserAccounts
    10/4/2007 11:41 AM container            Users

Want to see what’s in the Computers container? Then use this command:

Get-Childitem fabrikam:\computers

Not bad, not bad at all.

Extensions for Windows PowerShell

If you’re looking for stocking stuffers, why not pick up a copy of Sapien’s Extensions for Windows PowerShell (free download)? Although still in beta, this download includes some interesting little cmdlets, including cmdlets that can return information about available physical and virtual members; cmdlets that can output data to the Windows Text-to-Speech subsystem; and cmdlets that can return the names of the logged-on user, the local computer, and the local domain. How easy are these cmdlets to use? Well, here’s how you can determine whether or not your computer is connected to a network:

Test-NetConnection

We feel like a kid in a candy store.

Or at least a kid in a candy store that also sells PowerShell cmdlets.

PowerTab

And then there was: PowerTab.

As you probably know, out of the box Windows PowerShell includes some basic tab expansion. (OK, “out of the box” if PowerShell actually came in a box.) For example, type get-c in the PowerShell console and then press the TAB key; PowerShell will replace get-c with Get-ChildItem. Press TAB a second time and PowerShell will replace Get-ChildItem with Get-Command. In other words, PowerShell will methodically cycle through all the commands that start with get-c, allowing you to insert a cmdlet without having to type in the entire command name. Cool, huh? PowerShell’s built-in tab expansion also works for file system paths. For example, suppose C:\Scripts is the only folder on drive C whose name starts with the letter s. Perfect: type C:\S and press TAB. And then let PowerShell take it from there.

That’s all well and good, but it’s nothing compared to what PowerTab does. PowerTab is a cool little utility written by /\/\o\/\/, better-know as The PowerShell Guy. What’s so cool about PowerTab? Well, for one thing, PowerTab doesn’t just show you one possible value (e.g., Get-ChildItem), then require you to press TAB to see the next possible value (e.g., Get-Command). Instead, PowerTab gives you an IntelliSense dropdown list for selecting values:

Oh, and PowerTab doesn’t limit itself to PowerShell cmdlets and the file system; it also works with such things as WMI classes and.NET Framework classes. For example, with PowerTab loaded, type the following into the PowerShell console and press TAB; you should be pleasantly surprised by what you see:

Win32_S

Oh, right. If you don’t have a copy of PowerTab handy, this is what you would see:

That’s all right; you go ahead and cry. After all, it is a beautiful sight, isn’t it?

Next: Books