Technet Evening Exchange 2007 – Q&A and Powershell scripts Part I

On Wednesday June 7th I give Technet Evening about Exchange 2007, during this 2 hour session I give a Technical overview of Exchange 2007. I will not post a wrap-up of the session because Ilse Van Criekinge already did on her Pro-Exchange user group site. Ilse created a great article which is a good summary of my session.

What I will do here is post all scripts and commands I used to demo the Exchange Shell based on Monad Technology.

Remember the first demo’s I showed with the Exchange Management console.

  • Change the phone number of a user.
  • Create a new storagegroup with a new database. Mount the database and move the user(s) mailbox that start with a B.

I aimed to do the same within the Monad Shell, here are the cmdlets I used to perform the actions as described above:

Change the phone number of user Bob Kelly:

Get-user

 

Set-user bobk –phone 02123456

 

Get-user bobk | ft name, phone

List of users from AD

 

Set the new phone nr for bobk

 

Get the user info of bobk and show it in table form with only the phone name and phone nr

 

I used three commands to get the results I wanted however it was perfectly possible to have it done in two commands


Get-user bobk | set-user –phone 02123456

Get-user bobk | ft name, phone

 

This is just the beginning and imagine that you want to change the department of all users that are reporting to the HR Manager. Lets assume that you now who the HR manager is, in this case it is Kim Akers.

Change the department of Kim Akers direct reports:

Get-user | where { $_.manager –like “Kim Akers*” } | ft name,department

 

 

 

 

Get-user | where { $_.manager –like “Kim Akers*” } | Set-user –department “Human Resources”

Get all direct reports of Kim Akers and output the results into a table with the name and the department. I only used this command to show you that the department was empty (see screenshot)

 

 

Use the same command but pipe the output to the set-user command. The department has now been set to “Human Resources”. See screenshot for results. 

 

Creation of a new storagegroup, mailboxdatabase and move mailbox:

If you don’t know the exact cmdlets to create a storage group there is always the help command:

Get-Command *storage*

 

Once you know the command you can get the parameters with the following command:

 

Get-command New-storagegroup | format-list definition

 

 

New-storagegroup –Name TechnetDemo –server Smbex01

 

New-mailboxdatabase DB01 –Storagegroup TechnetDemo | mount-database

 

Get-mailbox | where { $_.name –like “T*”} | foreach { movemailbox *_.name –targetdabase DB01 -whatif}

 

 

 

 

 

 

Get-mailbox | where { $_.name –like “T*”} | foreach { movemailbox *_.name –targetdabase DB01}

Create a new storagegroup called TechnetDemo on the Smbex01 server

 

Create and mount the mailboxdatabase

 

 

 

Get all mailboxes and filter the ones where the username starts with a T and foreach of the move the mailbox to the DB01 database. As you can see I used the –whatif parameter to first have a look what would happen if I run this command. You can use the –validate parameter to test the actual move procedure.

 

Proceed with the actual move of the mailboxes.

So far for the first part of this blogpost. I will post the second part after the weekend.

Tags: Powershell, Monad, Exchange 2007