PowerShell and Exchange 2007

I am busy preparing the Belgian Technet Evening where I will give an overview of Exchange 2007. There will be an overview of the new ESM, the new features in Outlook Web Access and last but not least I will demo the power of “PowerShell” within Exchange 2007.

So after downloading my Exchange 2007 vpc, I started with the “PowerShell” scripting because, for me it is the coolest item in Exchange 2007 not.

How the heck do you start with this new scripting language? It’s quite simple we have 350 commands, called commandlets for Exchange 2007. This scripting language has been made very simple.

Let’s get started:

First I wanted to know which cmdlets there where available for Exchange 2007

  • Get-excommand

The output is a list with all cmdlets available for Exchange 2007.

As you can see the command are based on verb-noun principle.

As an Exchange administrator you want to know which mailboxes there are on my Exchange 2007 environment. If you want to do that with VBscripting, you will have to write quite some lines to get this information.

In PowerShell it is only one command: get-mailbox

This command returns us the list of mailboxes available on your exchange servers.

Let’s take a look at only one user Terry Adams for example: get-mailbox terrya

As you can see it is the same table but only for Terry Adams, now every object have different properties. If you want to see which properties the get-mailbox command has you can run the same command and pipe the results to a format-list which will return all the properties of the get-mailbox object.

An example: get-mailbox terrya | format-list

This screenshot gives only a few of the properties of the get-mailbox object.

Let’s try something more complex to do, for instance let’s change the quota for all users starting with the letter “t” and give them a mailbox limit to 100MB.

Now you need to know which command will help us achieving our goal.

Get-mailbox terrya | fl “*quota*” this command will get all Quota properties for Terry Adams. Yes you can use wildcards so I could also use “*qu*” .

This is done deal now lets return all the users that start with a “t”:

Get-mailbox | where {$_.name –like “*t*”}

Now the final command and set the quota for the users:

Get-mailbox | where {$_.name –like “*t*”} | set-mailbox -StorageQuota 100mb

The screenshot shows you that we changed the storagequota of all users starting with “t” from unlimited to 100mb with only one command line.

I will end this “PowerShell scripting” blogpost here. I showed only some of the basics of “PowerShell”.


Don’t you find this awesome I do.

By the way I just created this post using Word 2007 – Beta 2 want to know more about blogging with Office 2007 Beta2, read this blogpost

Tags: Microsoft, Exchange , Monad, PowerShell, Scripting