Dec 6, 2009

The Exchange Management Shell for Exchange Server 2007

The Exchange Management Shell is new to Exchange Server 2007. The basic idea behind the shell is that it is a command and scripting interface.

Figure 19: This is what the Exchange Management Shell looks like.


Figure 19

It may first appear as if the Exchange Management Shell is nothing more than a standard command prompt. But if you look at the bottom line of text in Figure 19, you will notice that the letters "MSH" appear in brackets just ahead of the path.

The [MSH] tells you that you are not running in a true command prompt environment, but rather within a Microsoft Scripting Host shell. The Exchange Management Shell is nothing more than a Microsoft Scripting Host environment that has been extended to support Exchange Server commands.

So what types of commands can you run within the Exchange Management Shell? Exchange Server 2007 has been designed so that anything that you can do through the GUI can also be done through the Exchange Management Shell.

The available commands and all of the things you can do with the Exchange Management Shell are almost endless -- and definitely beyond the scope of this tutorial. However, I do want to show you a couple of quick tricks you can perform with the Exchange Management Shell.

The first trick involves using the get-ExchangeServer command. If you type this command by itself, the Exchange Management Shell will attempt to display all of the server roles that are configured on the server. However, because of the way that the information is formatted, you'll be able to see very little of the actual information. But, if you append the |format-list option to the command, the Exchange Management Shell will display a very nice summary of how your server is configured.

Figure 20: Entering the get-ExchangeServer|format-list command.


Figure 20

Now let me show you an example of how the Exchange Management Shell can be used for scripting. As you have worked with the Exchange Management Console, you might have noticed that some rather bizarre commands are displayed after completing certain actions. For example, if you look at Figure 21, you will see the New Mailbox screen. To get the screen, I created a mailbox for a new user named "User3."

Figure 21: Many of the actions that you perform through the Exchange Management Console will reveal commands that can be used to perform the exact same action from a command prompt.


Figure 21

There's nothing especially remarkable about creating a new user account and a new mailbox (except that you can do it all through the Exchange Management Console now). However, if you look at Figure 21 again, you'll see an extremely long command following the mailbox creation. This is the actual command that you would enter into the Exchange Management Shell if you wanted to create the new user and the new mailbox from the command prompt.

OK, I know that nobody in the right mind would want to type such a long command when they can perform the action through the GUI. That isn't really the point though. I'm showing this to you because you can use this command -- or other commands revealed through the Exchange Management Console -- as the basis for a script.

Imagine for example that you had a couple thousand mailboxes to create. It would be a lot faster to create a script based on the command that I just showed you then it would be to manually create the mailboxes through the GUI.

No comments:

Post a Comment