sus42

A Blog on Wndows Server and Microsoft Exchange by Thomas Pätzold

The Exchange 2010 Powershell SnapIns

leave a comment »


Applies to Exchange 2010 SP1

If you start the Exchange Management Shell, a Powershell instance is started and the Powershell remoting feature is used in order to establish a connection to the Exchange Server System. There is another option to load the Exchange 2010 specific commands in Powershell. In this case you have to start the Powershell and load the necessary Exchange 2010 management snapins.

The following three Exchange 2010 Snapins are available

Microsoft.Exchange.Management.PowerShell.E2010
Microsoft.Exchange.Management.PowerShell.Setup
Microsoft.Exchange.Management.Powershell.Support

In order to load the snapins you are able to use the following command

add-pssnapin -Name Microsoft.Exchange.Management.PowerShell.E2010

If you are writing a Powershell script, it might be useful to check if the plugin is loaded. In order to do this you are able to use the following code snipset.

if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) )
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:Stop
}

What is the difference between the Exchange Management Shell and adding the Exchange snapin to the Powershell session?

  1. The Exchange commands using the Exchange Management Shell are implemented as functions. If you load the “Microsoft.Exchange.Management.PowerShell.E2010” snapin instead of using the Exchange Management Shell the commands are implemented as cmdlets.
  2. Using the Exchange Management Shell you are able to take a more detailed look at how the functions better called the wrapper functions are implemented by using the command.
    get-command get-mailbox -detailed | select-object scriptblock
    

  3. There is one more important diffrence. If you want to use the systemvariable $? it is better to use the loaded snapin instead of the Exchange Management Shell because these commands don´t work properly in the Exchange Managemnt Shell. A second problem is the use of the common parameters because they are not implemented for all functions in Exchange Management Shell.

If you want to start an Exchange Shell Session because you want to execute your command on a special Exchange Server then this is possible but keep the limitations of the Exchange Management Shell in mind.

Advertisements

Written by Thomas Pätzold

September 14, 2011 at 9:10 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: