Home > Articles > Microsoft > MCTS

Managing Exchange Server 2010 with PowerShell

The Exchange Management Shell (EMS) within Microsoft Exchange Server 2010 includes many PowerShell cmdlets you can use to automate many administrative tasks. This article demonstrates its power by showing how you can modify the warning quota for a single mailbox using the PowerShell Set-Mailbox cmdlet, and then expanding this usage with the Get-Mailbox cmdlet and piping. It includes commands to configure the setting for all the mailboxes in an OU, in a database, on a server, or in the entire organization.
Like this article? We recommend

The Exchange Management Shell (EMS) builds on Windows PowerShell 2.0 and gives you a wealth of additional tools you can use to manage Microsoft Exchange 2010.

If you manage a Microsoft Exchange Server 2010 environment, you probably do a lot of your work in the Exchange Management Console. You can use this graphical user interface (GUI) to complete most of your tasks, but if you master some of the commands in the EMS, you’ll find you can complete many of your tasks more quickly and easily.

For example, the GUI often only allows you to work on a single object at a time. With the EMS, you can modify settings for individual mailboxes, all the mailboxes in an OU, all the mailboxes on a server, all the mailboxes in a database, or even all the mailboxes within an organization.

Setting the Warning Quota

Most organizations set limits on the size of user mailboxes. The warning quota sets a threshold for mailbox size, and Exchange sends a warning message to the user when the mailbox reaches the threshold.

Sometimes you want everyone in the organization to have the same warning quota. Other times, you may want to have different quotas set for different groups of users, such as users in an OU, database, or server. If you use the GUI, you’re limited on how you can set this quota. However, if you use PowerShell, you have many more capabilities.

The following examples show you the syntax to configure the warning quota for mailboxes at different levels of your Exchange organization.

Set the Warning Quota for a Single Mailbox

You probably won’t set the warning quota for an individual user with PowerShell. However, it’s useful to understand the basic cmdlet before expanding it to modify multiple users.

The basic syntax of the Set-Mailbox cmdlet is:

Set-Mailbox -Identity UserName -IssueWarningQuota size 
 -UseDatabaseQuotaDefaults $boolean value

The -Identity switch identifies the name of the user that owns the mailbox. The -IssueWarningQuota switch configures the warning quota and accepts an integer followed by KB, MB, or GB as sizes (without a space). For example, if you want to set the warning quota to 500 MB, the value of size is 500MB or if you want to set it to 1 GB, the value of size is 1GB. The $boolean parameter identifies if the user will inherit the quota values set on the database. This value is set to $false when configuring individual settings so that the user setting overrides the database setting.

The following cmdlet will set the warning quota for a user named Darril to 500 MB:

Set-Mailbox -Identity Darril -IssueWarningQuota 500MB 
 -UseDatabaseQuotaDefaults $boolean $false

There is much more you can do with the Set-Mailbox cmdlet. However, the focus here is only on showing how you can use the cmdlet to configure a setting, and then expand that knowledge to configure multiple settings.

Set the Warning Quota for All Users in an OU

If you’re tasked with reconfiguring the warning quota for all the users within an OU, you probably don’t want to do it manually for all the users. Instead, you can use the Get-Mailbox cmdlet to retrieve a list of mailboxes in an OU, and then pipe the results to the Set-Mailbox cmdlet. This following command shows the basic syntax:

Get-Mailbox -OrganizationalUnit OUname | 
 Set-Mailbox -IssueWarningQuota size 
 -UseDatabaseQuotaDefaults $boolean value

In this command, the Get-Mailbox cmdlet is first used to retrieve all the mailboxes within an OU. The pipe command (|) then directs PowerShell to send the output of the Get-Mailbox cmdlet to the following cmdlet (Set-Mailbox). Notice that the Set-Mailbox cmdlet doesn’t need the -Identity switch used to configure the setting for a single user. Instead, the Set-Mailbox cmdlet operates on all the mailboxes returned from the Get-Mailbox cmdlet.

If you wanted to set the warning quota for all mailboxes in the Sales OU to 500 MB, you’d use this command:

Get-Mailbox -OrganizationalUnit Sales | 
 Set-Mailbox -IssueWarningQuota 500MB 
 -UseDatabaseQuotaDefaults $boolean $false

Set the Warning Quota for All Users in a Database

You can set the warning quota for all users in a database using the same technique used to set the quota for all users in an OU. Here’s the basic syntax:

Get-Mailbox -Database DatabaseName | 
 Set-Mailbox -IssueWarningQuota size 
 -UseDatabaseQuotaDefaults $boolean value

Notice that the Get-Mailbox cmdlet has been modified to retrieve mailboxes in a database using the -Database switch. The result is piped to the Set-Mailbox cmdlet, just as it was piped in the previous example configuring all the mailboxes in an OU.

The following command will set the warning quota for all mailboxes in the database named SalesDB to 500 MB:

Get-Mailbox - Database SalesDB | 
 Set-Mailbox -IssueWarningQuota 500MB 
 -UseDatabaseQuotaDefaults $boolean $false

Set the Warning Quota for All Users on a Server

If you understand the commands to configure all the mailboxes in an OU or database, it becomes trivial to do the same thing for all mailboxes on a server. Here’s the basic syntax:

Get-Mailbox -Server ServerName | 
 Set-Mailbox -IssueWarningQuota size 
 -UseDatabaseQuotaDefaults $boolean value

The only thing that’s changed is in the Get-Mailbox cmdlet. The -Server switch is added with the ServerName parameter to identifythe name of the mail server.

If you wanted to set the warning quota for all mailboxes on a server named Mail1 to 500 MB, you could use the following command.

Get-Mailbox - Server Mail1 | 
 Set-Mailbox -IssueWarningQuota 500MB 
 -UseDatabaseQuotaDefaults $boolean $false

Set the Warning Quota for All Users in an Organization

This last example shows the syntax to configure this setting for all the users in the Exchange organization. Here’s the basic syntax:

Get-Mailbox | 
 Set-Mailbox -IssueWarningQuota size 
 -UseDatabaseQuotaDefaults $boolean value

Notice the Get-Mailbox cmdlet doesn’t include any switches to filter the output. Instead, it retrieves a list of all the mailboxes. As before, the output is piped to the Set-Mailbox cmdlet. Here’s the full command:

Get-Mailbox | 
 Set-Mailbox -IssueWarningQuota 500MB 
 -UseDatabaseQuotaDefaults $boolean $false

Use the Power with Care

While the PowerShell cmdlets included with EMS provide you with a great deal of power, it’s worth mentioning these should be used with care. You can quickly modify multiple objects within your organization saving you countless hours of tedium since you won’t have to do the tasks manually. However, if you make unwanted changes, it can just as easily result in countless hours of troubleshooting to get your system back to normal.

Testing is very important. The previous examples showed how to configure the warning quota for a single mailbox and multiple mailboxes. If you want to use these examples to modify a different setting, test your cmdlet on a single mailbox first. Once you’re satisfied with the result, expand the command to modify multiple mailboxes.

You can modify the results of the Get-Mailbox cmdlet using wildcards, the -filter switch, or by piping the results to a where clause. If you do, it’s worth your time to execute the Get-Mailbox cmdlet on its own to see the result before combining it with the Set-Mailbox cmdlet.

EMS is Much More than Two Cmdlets

While this article partially covered two EMS cmdlets (Get-Mailbox and Set-Mailbox), it’s important to realize that there is much more. Cmdlets are available to help with deployments, disaster recovery, recipient objects, roles, and much more. Additionally, these examples didn’t even show everything you can do with the Get-Mailbox and Set-Mailbox cmdlets. I’m betting you know this, but you can set much more than just the warning quota with the Set-Mailbox cmdlet.

However, you don’t have to master all of PowerShell and the EMS commands to use them. If you find a cmdlet gem that you like, you can use it to automate some administrative tasks without the need to master all of PowerShell.

Exchange Server 2010 Portable Command Guide

The information in this article was derived from the Exchange Server 2010 Portable Command Guide: MCTS 70-662 and MCITP 70-663 by Richard Robb and Darril Gibson published in June 2011. This book lists many of the common commands needed to pass the listed exams and commands regularly used on the job. It isn’t a massive tome including all the commands and switches you can possibly use, but instead is a portable take-anywhere guide to show you just what you need in your day-to-day administrative tasks.

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |