Chapter 5. Adding commands

 

One of the primary strengths of PowerShell is its extensibility. As Microsoft continues to invest in PowerShell, they develop more and more commands for products like Exchange Server, SharePoint Server, the System Center family, SQL Server, and so on. Typically, installing the management tools for these products gives you both a graphical management console of some kind and one or more extensions for Windows PowerShell.

5.1. How one shell can do everything

I know that you’re probably familiar with the graphical Microsoft Management Console (MMC), so let’s use that as an example of how PowerShell works. The two work similarly when it comes to extensibility, in part because both the MMC and PowerShell are developed by the same Management Frameworks team within Microsoft.

When you open a new, blank MMC console, it’s pretty useless. It can’t really do anything, because the MMC has very little built-in functionality. To make it useful, you go to its File menu and select Add/Remove Snapins. In the MMC world, a snap-in is some tool like Active Directory Users and Computers, or DNS Management, or DHCP Administration, or something like that. You can choose to add as many snap-ins to your MMC as you like, and you can save the resulting console so that it’s easier to re-open that same set of snap-ins in the future.

5.2. About product-specific management shells

5.3. Extensions: finding and adding snap-ins

5.4. Extensions: finding and adding modules

5.5. Command conflict and removing extensions

5.6. Finding help on newly added commands

5.7. Playing with Server Manager via command line!

5.8. Profile scripts: preloading extensions when the shell starts

5.9. Common points of confusion

5.10. Lab

5.11. Ideas for on your own