Seven Really Useful PowerShell Commandlets for Exchange
September 13, 2011 1 Comment
In my last blog post I talked about some of the many benefits of using PowerShell, Microsoft’s latest scripting language. PowerShell can help you save time when doing both mundane tasks and big jobs and it can allow you to easily access information that can be either difficult or impossible to get to through the GUI. In this post I’d like to share seven of my favorite, very useful PowerShell commandlets for use with Microsoft Exchange.
| Task | PowerShell Commandlet Syntax |
| Find all Mailboxes Forwarding to another e-mail address: | Get-Mailbox -resultsize unlimited | Where {$_.ForwardingAddress -ne $null} | Select Name, ForwardingAddress, DeliverToMailboxAndForward |
| Find out who has “Full Mailbox Access” permission on a mailbox | Get-Mailbox -Server “svrexmbx1” | Get-MailboxPermission | where { ($_.AccessRights -eq “FullAccess”) -and ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”) } |
| Create Address List based on Group Membership | Set-addresslist marketing-users -recipientfilter “MemberOfGroup -eq ‘CN=Marketing-Users,OU=Contoso-Groups,OU=Contoso,DC=Fabrikam,DC=local’” |
| Add mailbox database copy (DAG), and set Activation Preference | Add-MailboxDatabaseCopy -Identity ‘Sales-DB01′ –MailboxServer ‘SVREXMBX1′ -ActivationPreference ’2′ |
| Report on database usage: (DB Name & Size in GB) | get-mailboxdatabase -includepre | foreach-object{select-object -inputobject $_ -property *,@{name=”MailboxDBSizeinGB”;expression={[math]::Round(((get-item (“\\” + $_.servername + “\” + $_.edbfilepath.pathname.replace(“:”,”$”))).length / 1GB),2)}}} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB –autosize |
| Configure conference room bookingConfigure Auto-AcceptUser can request booking for anytime (“In Policy”)
Only members of “Resource Booking Permitted” can successfully book during business hours Same members can approve any request Show organizer info with calendar item Allow no more than 10% conflicts for request to be accepted |
Set-MailboxCalendarSettings SEAConfRm -AutomateProcessing AutoAccept -AllRequestInPolicy $True -AllRequestOutOfPolicy $True -AllBookInPolicy $False -BookInPolicy “Resource Booking Permitted” -ResourceDelegates “Resource Booking Permitted” -EnableResponseDetails $True -ForwardRequestsToDelegates $True -OrganizerInfo $True -TentativePendingApproval $True -ConflictPercentageAllowed 10 |
| Create new mailbox database on a specific serverSet Log and Database pathConfigure Default Offline Address list
Configure Public folder server/Database Set mailbox quotas Configure Deleted Item retention Configure Maintenance schedule |
New-MailboxDatabase -Name “US-MAIL-DB MDB 1″ -Server “US-MAIL-DB” -LogFolderPath “L:\Log1″ -EdbFilePath: “H:\MBXDB1\Priv01.edb” -OfflineAddressBook “Default Offline Address List” -PublicFolderDatabase “US-MAIL-DB PUBDB 0″ |Set-MailboxDatabase -IssueWarningQuota “450MB” -ProhibitSendQuota “500MB” -MailboxRetention “30.00:00:00″ -DeletedItemRetention “30.00:00:00″ -MaintenanceSchedule “Sun.1:00 AM-Sun.1:15 AM, Mon.1:00 AM-Mon.1:15 AM, Tue.1:00 AM-Tue.1:15 AM, Wed.1:00 AM-Wed.1:15 AM, Thu.1:00 AM-Thu.1:15 AM, Fri.1:00 AM-Fri.1:15 AM, Sat.1:00 AM-Sat.1:15 AM” -QuotaNotificationSchedule “Sun.1:00 AM-Sun.1:15 AM, Mon.1:00 AM-Mon.1:15 AM, Tue.1:00 AM-Tue.1:15 AM, Wed.1:00 AM-Wed.1:15 AM, Thu.1:00 AM-Thu.1:15 AM, Fri.1:00 AM-Fri.1:15 AM, Sat.1:00 AM-Sat.1:15 AM” -RetainDeletedItemsUntilBackup $True |
Based on my experience these will save you a great deal of time. What are some of the PowerShell commandlets that you find most useful? Please go ahead and share them here!

Pingback: Constructing PowerShell Commands « Coyote Creek