Weekend Shell: There is Only One PowerShell
I've recently been encountering a LOT of confusion about one of the basic aspects of how PowerShell works. The problem seems to arise because some of the Microsoft product teams, such as Exchange Server, create an "Exchange Management Shell" icon upon installation. This leads to the misperception that there are "many" PowerShells... and there aren't. There is only one PowerShell.
June 26, 2010
I've recently been encountering a LOT of confusion about one of the basic aspects of how PowerShell works. The problem seems to arise because some of the Microsoft product teams, such as Exchange Server, create an "Exchange Management Shell" icon upon installation. This leads to the misperception that there are "many" PowerShells... and there aren't.There is only one PowerShell.
PowerShell works a lot like the MMC in this regard. The MMC is empty, and not capable of much; you add snap-ins to give it functionality. Microsoft usually creates icons for consoles that pre-load certain snap-ins. That is, when you open Active Directory Users and Computers, you're opening the same old MMC - but it is pre-configured to load the ADUC snap-in.
That's how PowerShell works. There's one shell. It can be extended by snap-ins and by modules (which are close to the same thing - they're just different distribution mechanisms, and modules are the preferred way as of v2). If you open the "basic" shell, you can add the Active Directory module to manage AD, the SQL Server snap-in to work with that product, and so on.
Microsoft product teams often create a "management shell" icon when they install, but that icon isn't a brand-new version of PowerShell. It's just a shortcut that loads powershell.exe with a command-line parameter to pre-load a given snap-in - just like the MMC.
Like the MMC, PowerShell lets you load as many snap-ins (or modules) as you like. Want to combine SQL, AD, Exchange, and SharePoint? You can do that. And you can even export a "console file" (using Export-Console) that remembers which snap-ins you have loaded. Later, you can run PowerShell.exe with a command-line switch to re-load that entire "console," bringing all of your snap-ins back online.
The nice part about PowerShell is that you really only have to learn a limited set of "patterns" to use all of the various PowerShell snap-ins and modules. Learn to use the AD module, for example, and you're well on your way to understanding how the SharePoint module works, too. Eventually, you'll fall into an easy ability to understand new modules as Microsoft releases them, meaning your ongoing learning curve will be shallower, thanks to your initial PowerShell investment.
Update: In response to one of the comments below, let me clearly state that you CAN perform MULTIPLE tasks within a SINGLE shell session. On a Windows Server 2008 R2 machine, for example, I can run Import-Module ActiveDirectory to load the AD extension; I can then run Add-PSSnapin to add the Windows Backup features or the SQL Server extensions (assuming they're installed on that computer, of course). I can load the Exchange extensions into that same shell, too. This is EXACTLY how the MMC works - you aren't stuck using the default, single-purpose consoles Microsoft provides, and you're not stuck using the default single-purpose shell shortcuts, either. In fact, examine the shortcut for the Exchange Management Shell and you'll see that it's just running PowerShell.exe with a particular extension pre-loaded - you're not prevented from modifying that to load additional extensions by default, if you like.
About the Author
You May Also Like