Exchange 2010 and 2007 Useful Powershell Commands



Grant full access to all mailboxes

get-mailbox -server <exchange server Name> | Add-MailboxPermission -User “domain\userid” -AccessRights FullAccess

Move mailbox to another server

New-MoveRequest –identity username –TargetDatabase “database name”

Update Default Global Address List

Update-GlobalAddressList -Identity “default Global Address List”

Grant relay permission to send connector

Get-ReceiveConnector “Anonymous Relay” | Add-ADPermission -User “NT AUTHORITY\ANONYMOUS LOGON” -ExtendedRights “Ms-Exch-SMTP-Accept-Any-Recipient”

Remove Move Request

Remove-MoveRequest -identity boardroom

If a move fails you need to remove the move request before generating another one

Get information on size and number of items in mailbox store

get-mailboxstatistics -database “name-of-mail-database”

Get information on an individual mailbox

get-mailboxstatistics -identity administrator

Check autodiscover


Create hub site

Set-AdSite “Site A” -HubSiteEnabled $true

Approve in-policy requests from all users for the room mailbox “board room”.

Set-CalendarProcessing -Identity “boardroom” -AutomateProcessing AutoAccept -AllBookInPolicy $true

Prevent a user from deleting any items

Set-mailbox <username> LitigationHoldEnabled $true

Create a retention tag to delete emails older than 90 days from the “deleted items” folder

New-RetentionPolicyTag “AllUsers-DeletedItems” –Type DeletedItems –Comment “Items older than 90 days are deleted” –RetentionEnabled $true –AgeLimitForRetention 90 –RetentionAction PermanentlyDelete

Exports list of all user email addresses to a text file

get-recipient | select name -expand emailaddresses | where {$_.smtpAddress} | Select-Object Name,smtpAddress | export-csv c:\AllEmailAddresses.txt -noType

Upgrade Recipient Policy from older version of Exchange

Set-EMailAddressPolicy “Default Policy” -IncludedRecipients “AllRecipients”


Leave a Reply

Your email address will not be published. Required fields are marked *