This is more a reference for myself:
I covered the basics of message tracking in:
http://jim-zimmerman.com/?p=1098
How to get the full Exchange version:
Get-Command ExSetup | Format-List
Get-Command ExSetup | ForEach {$_.FileVersionInfo}
Here is a link to cross-reference the result to determine the service pack, etc.:
https://technet.microsoft.com/en-us/library/hh135098(v=exchg.150).aspx
Create a mailbox (and account):
New-Mailbox -Name âFirstName LastNameâ -Alias âUsernameâ -OrganizationalUnit âOranizational Unitâ -UserPrincipalName âUsername@DOMAIN.NAMEâ -SamAccountName âUsernameâ -FirstName âFirstNameâ -Initials â -LastName âLastNameâ -Password âTemporaryPasswordâ -ResetPasswordOnNextLogon $false -Database âMailboxDatabaseâ
Database size:
Get-MailboxDatabase -Status | Select Name,DatabaseSize
PublicFolderDatabase size:
Get-PublicFolderDatabase -Status | Select Name,DatabaseSize
To determine role assignments:
Get-ManagementRoleAssignment
Create a recovery mailbox:
New-MailboxDatabase -Recovery -Name âRecovery DB Nameâ -Server EXCHANGESERVERNAME
To check mailbox stats:
Get-MailboxDatabase -Status | Format-List Mame,DatabaseSize,AvailableNewMailboxSpace
Delete a mailbox database. Once removed, you can delete the files from the file system.:
Remove-MailboxDatabase -Identity âRecovery DB Nameâ
The right way to create a recovery database:
New-MailboxDatabase -Recovery -Name âRecovery DB Nameâ -Server EXCHANGESERVERNAME -EdbFilePath Drive:\Directory\Filename.edb -LogFolderPath Drive:\Directory
Move a mailbox:
You can use the canonical name of the object with the mailbox ( DOMAIN.LOCAL/OU/OU/Name ) to move from EMS.
Note: You may need to enable inheritance. This can be dome from the ADUC. Access the Properties for the user and click on Security tab. If it is not visible, you need to enable your ADUC view for Advanced Features. Once on the Security tab, click Advanced, and then down in the bottom left click âEnable inheritanceâ. This is on a Windows 2012 R2 domain controller. It might a little different dialog on older versions of Windows server.
[PS] >âDOMAIN.LOCAL/TahityOU/SurfingOU/Cool Dudeâ | New-MoveRequest -TargetDatabase âMy Exchange Databaseâ
DisplayName Status TotalMailboxSize TotalArchiveSize PercentCompl
ââââ ââ âââââ- âââââ- ââââ
Cool Dude Queued 5 B (5 bytes) 0
Check the status of all move requests:
[PS] >Get-MoveRequest
Check Cool Dudeâs move request:
[PS] >Get-MoveRequest -Identity âcooldude@tahiti.surfingâ
Nice, but what do I do to get all those canonical names?
The following will give you all the canonical names for all objects in your domain. From a domain controller, fire up powershell:
PS > Get-AdUser -Properties CanonicalName -Filter â*â | Select CanonicalName
I am sure there is a better way to do this, but this will give some output that will have the CanonicalName and Exchange mail server for an object. You can work with this output to come with a list that of objects that need to be moved.
PS > Get-AdUser -Properties CanonicalName,msExchHomeServerName -Filter â*â | Select CanonicalName,msExchHomeServerName | Format-List
I have noticed that sometimes when I move a mailbox from one database to another and then I display mailbox statistics, I will have two different results for the same mailbox. To find these, you need you use Get-MailboxStatistics and filter for MailboxState of SoftDeleted:
PS > Get-MailboxStatistics -server servername | Select DisplayName,DisconnectReason,Database | findstr âSoftDeletedâ
And then to remove the SoftDeleted version of the mailbox:
PS > Remove-StoreMailbox -Identity âmailboxidentityâ -Database âmailboxdatabaseâ -MailboxState SoftDeleted
If you have previously moved a mailbox and need to move it again, you will need to remove the old move request even though it is completed. To do so:
PS> Remove-MoveRequest -Identity âCool Dudeâ
This will create a Send Connector for use in your LAN. In my case, it is a linux server. Create a Send Connector:
New-SendConnector -Name âSome Nameâ -Usage âInternalâ -AddressSpaces âSMTP:hostORdomainname;1â -IsScopedConnector $false -DNSRoutingEnabled $false -SmartHosts â[aaa.bbb.ccc.ddd]â -SmartHostAuthMechanism âNoneâ -UseExternalDNSServersEnabled $false -SourceTransportServers âMY-EXCHG01â
Create a new mail contact:
New-MailContact -ExternalEmailAddress âSMTP:mycontact@email.addressâ -Name âmycontactâ -Alias âmycontactâ -FirstName âMyâ -Initials âMCâ -LastName âContactâ -OrganizationalUnit âDOMAIN.LOCAL/OU/OUâ
To create and email box to an existing ADS account:
Enable-Mailbox -Identity âDOMAIN.LOCAL/OU/ADSAccountâ -Alias âmyownaliasâ
Enable a contact for a existing contact:
Enable-MailContact -Identity âDOMAIN.LOCAL/OU/ContactNameâ -ExternalEmailAddress âSMTP:my@external.emailaddressâ -Alias âmyAliasâ
To check and make active components:
[PS] C:\> Get-ServerComponentState
Server Component State
ââ âââ ââ
VMEXCHG2013.greattechhelp.local ServerWideOffline Inactive
VMEXCHG2013.greattechhelp.local HubTransport Inactive
VMEXCHG2013.greattechhelp.local FrontendTransport Inactive
VMEXCHG2013.greattechhelp.local Monitoring Inactive
VMEXCHG2013.greattechhelp.local RecoveryActionsEnabled Inactive
VMEXCHG2013.greattechhelp.local AutoDiscoverProxy Inactive
VMEXCHG2013.greattechhelp.local ActiveSyncProxy Inactive
VMEXCHG2013.greattechhelp.local EcpProxy Inactive
VMEXCHG2013.greattechhelp.local EwsProxy Inactive
VMEXCHG2013.greattechhelp.local ImapProxy Inactive
VMEXCHG2013.greattechhelp.local OabProxy Inactive
VMEXCHG2013.greattechhelp.local OwaProxy Inactive
VMEXCHG2013.greattechhelp.local PopProxy Inactive
VMEXCHG2013.greattechhelp.local PushNotificationsProxy Inactive
VMEXCHG2013.greattechhelp.local RpsProxy Inactive
VMEXCHG2013.greattechhelp.local RwsProxy Inactive
VMEXCHG2013.greattechhelp.local RpcProxy Inactive
VMEXCHG2013.greattechhelp.local UMCallRouter Inactive
VMEXCHG2013.greattechhelp.local XropProxy Inactive
VMEXCHG2013.greattechhelp.local HttpProxyAvailabilityGroup Inactive
VMEXCHG2013.greattechhelp.local ForwardSyncDaemon Inactive
VMEXCHG2013.greattechhelp.local ProvisioningRps Inactive
VMEXCHG2013.greattechhelp.local MapiProxy Inactive
VMEXCHG2013.greattechhelp.local EdgeTransport Inactive
VMEXCHG2013.greattechhelp.local HighAvailability Inactive
VMEXCHG2013.greattechhelp.local SharedCache Inactive
To make all your configured components active:
[PS] C:\>Set-serverComponentState -Identity vmexchg2013 -Component ServerWideOffline -State Active -Requester Functional
Check again:
[PS] C:\> Get-ServerComponentState
Server Component State
ââ âââ ââ
VMEXCHG2013.greattechhelp.local ServerWideOffline Active
VMEXCHG2013.greattechhelp.local HubTransport Active
VMEXCHG2013.greattechhelp.local FrontendTransport Active
VMEXCHG2013.greattechhelp.local Monitoring Inactive
VMEXCHG2013.greattechhelp.local RecoveryActionsEnabled Inactive
VMEXCHG2013.greattechhelp.local AutoDiscoverProxy Active
VMEXCHG2013.greattechhelp.local ActiveSyncProxy Active
VMEXCHG2013.greattechhelp.local EcpProxy Active
VMEXCHG2013.greattechhelp.local EwsProxy Active
VMEXCHG2013.greattechhelp.local ImapProxy Active
VMEXCHG2013.greattechhelp.local OabProxy Active
VMEXCHG2013.greattechhelp.local OwaProxy Active
VMEXCHG2013.greattechhelp.local PopProxy Active
VMEXCHG2013.greattechhelp.local PushNotificationsProxy Active
VMEXCHG2013.greattechhelp.local RpsProxy Active
VMEXCHG2013.greattechhelp.local RwsProxy Active
VMEXCHG2013.greattechhelp.local RpcProxy Active
VMEXCHG2013.greattechhelp.local UMCallRouter Active
VMEXCHG2013.greattechhelp.local XropProxy Active
VMEXCHG2013.greattechhelp.local HttpProxyAvailabilityGroup Active
VMEXCHG2013.greattechhelp.local ForwardSyncDaemon Active
VMEXCHG2013.greattechhelp.local ProvisioningRps Active
VMEXCHG2013.greattechhelp.local MapiProxy Inactive
VMEXCHG2013.greattechhelp.local EdgeTransport Active
VMEXCHG2013.greattechhelp.local HighAvailability Active
VMEXCHG2013.greattechhelp.local SharedCache Active
Enter Product License Key:
Set-ExchangeServer -Identity âMY-EXCHG01â -ProductKey âAAAAA-BBBBB-CCCCC-DDDDD-EEEEEâ
List Services:
[PS] C:\>Get-Service
Status Name DisplayName
ââ â- ââââ
Stopped AeLookupSvc Application Experience
Stopped ALG Application Layer Gateway Service
Stopped AllUserInstallA⊠Windows All-User Install Agent
Running AppHostSvc Application Host Helper Service
Stopped AppIDSvc Application Identity
Stopped Appinfo Application Information
Stopped AppMgmt Application Management
Stopped aspnet_state ASP.NET State Service
Stopped AudioEndpointBu⊠Windows Audio Endpoint Builder
Stopped Audiosrv Windows Audio
Stopped AxInstSV ActiveX Installer (AxInstSV)
Running BackupExecAgent⊠Backup Exec Remote Agent for Windows
Running BackupExecAgent⊠Backup Exec Agent Browser
Running BackupExecDevic⊠Backup Exec Device & Media Service
Running BackupExecJobEn⊠Backup Exec Job Engine
Running BackupExecManag⊠Backup Exec Management Service
Running BackupExecRPCSe⊠Backup Exec Server
Running bedbg Backup Exec Error Recording Service
âŠ
Find a service:
[PS] C:\>Get-Service | findstr Inform
Stopped Appinfo Application Information
Running MSExchangeIS Microsoft Exchange Information Store
Restart and service:
[PS] C:\>Restart-Service MSExchangeIS
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
WARNING: Waiting for service âMicrosoft Exchange Information Store (MSExchangeIS)â to finish stoppingâŠ
Check and Modify Role Memberships:
First, the âOrganization Managementâ Role is the most powerful role in Exchange 2010 and Exchange 2013.
To list the members of a role:
[PS] >Get-RoleGroupMember âOrganization Managementâ
Creating a new session for implicit remoting of âGet-RoleGroupMemberâ commandâŠ
Name RecipientType
â- ââââ-
Administrator UserMailbox
To add somebody to a role:
[PS] >Get-RoleGroupMember âOrganization Managementâ
Name RecipientType
â- ââââ-
Administrator UserMailbox
Jim Zimmerman UserMailbox
Here is list of Exchange roles in Exchange 2010. I believe most of these are in Exchange 2013 too:
https://technet.microsoft.com/en-us/library/dd638077%28v=exchg.141%29.aspx
Connector commands:
List Connectors:
[PS] C:\>Get-ReceiveConnector
Identity Bindings Enabled
âââ âââ ââ-
MYEXSERVER\Default MYEXSERVER {:::25, 0.0.0.0:25} True
MYEXSERVER\Client MYEXSERVER {:::587, 0.0.0.0:587} True
MYEXSERVER\Non-Exchange Relay Support {0.0.0.0:25} True
[PS] C:\>Get-SendConnector
Identity AddressSpaces Enabled
âââ ââââ- ââ-
Production SMTP Connector {SMTP:*;1} True
To see all the settings for a single connector:
[PS] C:\>Get-ReceiveConnector âMYEXSERVER\Non-Exchange Relay Supportâ | Format-List
âŠ
To change a setting for a connector:
[PS] C:\>Get-ReceiveConnector âMYEXSERVER\Non-Exchange Relay Supportâ -ProtocolLoggingLevel Verbose
A note on connector logging:
The connector logs are stored on the Transport Hub server in the ExchangeInstallPath\TransportRoles/Logs/ProtocolLog/SmtpReceive for the receive connectors, and ExchangeInstallPath\TransportRoles/Logs/ProtocolLog/SmtpSend for the send connectors.
Also, in a mixed version environment, the connector may have to be âupgradedâ to support logging. I was not able to turn on the the logging for my old Exchange 2003 connectors. Upgrading basically consists of deleting and creating again.
To view basic information about a mailbox:
[PS] C:\>Get-Mailbox âmailboxnameâ
To view detailed information about a mailbox:
[PS] C:\>Get-Mailbox âmailboxnameâ | Format-List
To filter that list:
[PS] C:\>Get-Mailbox âmailboxnameâ | Format-List properties
Or:
[PS] C:\>Get-Mailbox âmailboxnameâ | Select properties
To see mailbox usage, number of items, etc:
[PS] C:\>Get-MailboxStatistics âmailboxnameâ
Which you can filter as well:
[PS] C:\>Get-MailboxStatistics âmailboxnameâ | Format-List properties
[PS] C:\>Get-MailboxStatistics âmailboxnameâ | Select properties
View mailboxes and sort them by size:
[PS] C:\>Get-MailboxStatistics | Select DisplayName,TotalItemSize,LastLoggedOnUserAccount,LastLogonTime | Sort-Object -Property TotalItemSize
This works too:
[PS] C:\>Get-MailboxStatistics -Server servername | Select DisplayName,ItemCount,TotalItemSize | Sort TotalItemSize
To view mailbox logon information:
[PS] C:\>Get-LogonStatistics âmailboxnameâ
To view who has access to a mailbox:
[PS] C:\>Get-MailboxPermission âmailboxnameâ
Add mailbox permission:
[PS] C:\>Add-MailboxPermission -Identity âmailboxidentityâ -User âdomain\usernameâ -AccessRights âFullAccessâ
Remove mailbox permission:
[PS] C:\>Remove-MailboxPermission -Identity âmailboxidentityâ -User âdomain\usernameâ -AccessRights âFullAccessâ
Move a mailbox:
[PS] C:\>âcntouseraccountâ | New-MoveRequest -TargetDatabase âdatabasenameâ
Example:
[PS] C:\>âMY.DOMAIN/MYOU/my nameâ | New-MoveRequest -TargetDatabase âMYEXCHANGEDBâ
To check move request statuses:
[PS] C:\>Get-MoveRequest
For more detail, like how far a move has progressed:
[PS] C:\>Get-MoveRequestStatistics -IncludeReport
To set the bad item limit for a mailbox that has partially been transferred:
[PS] C:\>Set-MoveRequest -Identity ĂąâŹĆmy nameĂąâŹÂ -BadItemLimit numberofitems
To resume a failed mailbox move:
[PS] C:\>Resume-MoveRequest âmy nameâ
To move a mailbox that has some corrupted items (in this case, one):
[PS] C:\>âMY.DOMAIN/MYOU/my nameâ | New-MoveRequest -BadItemLimit 1 -TargetDatabase âMYEXCHANGEDBâ
If you have a lot of issues:
[PS] C:\>âMY.DOMAIN/MYOU/my nameâ | New-MoveRequest -BadItemLimit 100 -AcceptLargeDataLoss -TargetDatabase âMYEXCHANGEDBâ
Note: these items will then not be migrated over the new location.
To count the number of items in some output use Measure-Object:
This more of a PowerShell tip than an EMS tip, but it is good to know when using EMS.
[PS] C:\>Get-Mailbox | Measure-Object
Count : 124
Average :
Sum :
Maximum :
Minimum :
Property :
To check the mail queues:
Get-Queue
To retry or process messages in a queue:
Queue notes:
Check queues:
[PS] C:\>Get-Message -Server servername
To check the queues:
Get-Queue
To force the messages in a queue to try again:
Retry-Queue -Filter {status -eq âretryâ}
To try one queue againâ
Retry-Queue -Identity Server\Queue
Remove a message from a queue:
[PS] C:\>Remove-Message -Identity messageidentity
[PS] C:\>Write-Output Output something.
To count the number message received on a day:
[PS] C:\>Get-MessageTrackingLog -Start âmm/dd/yyyy 00:00âł -End âmm/dd/yyyy 23:59âł -EventID RECEIVE | Measure-Object
To find mailbox sizes and sort by size:
[PS] C:\>Get-MailboxStatistics -Server servername | Select DisplayName,TotalItemSize | Sort TotalItemSize
To remove automapping. Or how to grant access to a mailbox and not enable AutoMapping like the UI does:
[PS} C:\>Add-MailboxPermission -Identity mailboxname -User username -AccessRight FullAccess -InheritanceType All -Automapping $false