Exchange 2010 PowerShell Cheat Sheet PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Useful

PowerShell Cmdlets for Exchange 2010

Mailbox Permissions

Mailbox Management

CmdLet
Description
Add-MailboxPermission
Grant a user permission to access another users Mailbox
Get-MailboxPermission
View the permissions that are assigned to a Users Mailbox
Remove-MailboxPermission
Remove the permissions from a user to access another users mailbox
Add-ADPermission
Adds Active Directory Permissions to a User Account
Remove-ADPermission
Removes Active Directory Permissions from a User Account
Examples:
AddMailboxPermission Identity Steve.Smith User Jane.Smith AccessRights FullAccess
Grants Jane Smith full access to Steve Smiths mailbox.
AddADPermission identity Steve.Smith User Jane.Smith AccessRights ExtendedRight ExtendedRights Send
As
Grants Jane Smith Send As rights on Steve Smiths Mailbox

CmdLet
Description
Get-Mailbox
View information about mailboxes.
New-Mailbox
Create a new user and give them a mailbox
Remove-Mailbox
Delete an AD User account and the associated mailbox
Enable-Mailbox
Mailbox-enable an existing AD user that does not have a mailbox
Set-Mailbox
Change the settings of an existing mailbox.
Get-MailboxStatistics Get information about a mailbox (Size, item count etc.)
Examples:
EnableMailbox Steve.Smith
MailEnables the AD account named Steve.Smith
GetMailbox | GetMailboxStatistics | Sortobject TotalItemSize | SelectObject
DisplayName,Database,TotalItemSize,ItemCount,StorageLimitStatus | ExportCsv MailboxStats.csv
Exports a CSV of Mailbox information for your organization.

CmdLet
Get-MoveRequest

Group Management
CmdLet
Get-DistributionGroup

Mailbox Moves

Description
View information about specified distribution groups or retrieve a list
of the distribution groups stored within your Organization. (This
includes Mail-enabled security groups)
Create a distribution group.
Delete a distribution group.
Change the properties of an existing distribution group.
Add a recipient to an existing distribution group.
View the members of an existing distribution group.
Delete a recipient from the membership of a distribution group.

New-MoveRequest
Remove-MoveRequest

Description
View the status of an ongoing mailbox move that was initiated by the
New-MoveRequest CmdLet.
Create a new mailbox move.
Cancel a mailbox move that was initiated by the New-MoveRequest
CmdLet.
Resume a suspended or failed move request.
Change the properties of an existing move request.
Suspend a move request before it reaches the status of
CompletionInProgress.
View detailed information about move requests

New-DistributionGroup
Remove-DistributionGroup
Set-DistributionGroup
Add-DistributionGroupMember
Get-DistributionGroupMember
Remove-DistributionGroupMember
Examples
NewDistributionGroup Senior Managers OrganizationalUnit Contoso.com\Distribution Lists type
Distribution DisplayName Senior Management Team
Creates a new distribution group named Senior Managers in the Distribution Lists OU. This group will appear as
Senior Management Team in the Address Lists.
AddDistributionGroupMember identity Senior Managers member Contoso\Steve.Smith
Adds Steve Smith to the Senior Managers OU

Resume-MoveRequest
Set-MoveRequest
Suspend-MoveRequest

Inbox Rules

CmdLet
Description
Get-Help
Retrieve help information for PowerShell Cmdlets
Examples:
GetHelp GetMailbox
This provides basic information about the GetMailbox CmdLet
GetHelp GetMailbox Detailed
This Provides detailed information about the GetMailbox CmdLet including what parameters it can take
GetHelp GetMailbox Examples
This provides examples of how to use the GetMailbox CmdLet

CmdLet
Description
Get-InboxRule
Retrieve a list of Inbox Rules from a Users Mailbox
Examples:
GetInboxRule mailbox Steve.Smith
This retrieves all inbox rules for the Steve Smith Mailbox.

Get-MoveRequestStatistics
Examples:
GetMailbox SteveSmith | NewMoveRequest TargetDatabase MBXDatabase1
Creates a Move request to move the Steve Smith Mailbox to the MBXDatabase1 Database
GetMailbox database Database1 | newMoveRequest BadItemLimit 10 TargetDatabase Database2
This command creates move requests for all mailboxes on Database1 and sets the Corrupt Item Limit to 10
GetMoveRequest | GetMoveRequestStatistics
Returns detailed information for the current move requests

PowerShell Help

Database Management

Test Cmdlets

CmdLet
Description
Mount-Database
Mounts a Database in the Exchange Organization
Dismount-Database
Dismounts a database in the Exchange Organization
Get-MailboxDatabase
Retrieves information about a Mailbox Database
New-MailboxDatabase
Creates a new Mailbox Database
Set-MailboxDatabase
Sets properties on a Mailbox Database
Add-MailboxDatabaseCopy
Adds a new copy of a specified Mailbox Database
Get-MailboxDatabaseCopy
Retrieves information about a Mailbox Database Copy
Set-MailboxDatabaseCopy
Sets properties on a Mailbox Database Copy
Suspend-MailboxDatabaseCopy
Suspends replication and replay for a specified Database Copy
Resume-MailboxDatabaseCopy
Resumes replication and reply for a specified Database Copy
Move-DatabasePath
Moves the path of a Mailbox Database
Move-ActiveMailboxDatabase
Performs a Database Switchover
Get-MailboxDatabaseCopyStatus Retrieve information about the status of a Mailbox Database Copy
Examples:
GetMailboxDatabase identity Database1
Retrieves information about Database1
AddMailboxDatabaseCopy identity Database1 MailboxServer Server3 ActivationPreference 3
Adds a copy of Database1 to Mailbox Server Server3 with an activation preference of 3
MoveActiveMailboxDatabase identity Database1 ActivateOnServer Server3
Switches Database1 to Server3

CmdLet
Description
Test-MapiConnectivity
Tests connectivity to databases
Test-MRSHealth
Tests the health of the Mailbox Replication Service
Test-AssistantHealth
Tests the health of the Mailbox Assistants
Test-ExchangeSearch
Tests that Exchange Search is enabled and indexing
Test-OutlookWebServices
Tests the Autodiscover settings for Outlook
Test-WebServicesConnectivity
Tests that Exchange Web Services are functioning correctly
Test-OwaConnectivity
Tests that OWA is running as expected
Test-ActiveSyncConnectivity
Tests that Activesync is functioning as expected
Test-OutlookConnectivity
Tests that Outlook will connect as expected
Test-Mailflow
Tests that Mailflow is functioning correctly within the Organization
Test-ReplicationHealth
Test all aspects of replication and replay for a Mailbox Server
Examples:
TestMapiConnectivity Server Server1
Tests that Server1 is accessible

Server Management
CmdLet
Description
Get-DatabaseAvailabilityGroup
Retrieve information about a Database Availability Group
Set-DatabaseAvailabilityGroup
Sets properties of a DatabaseAvailabilityGroup
AddAdds a mailbox server into a Database Availability Group
DatabaseAvailabilityGroupServer
RemoveRemoves a mailbox server from a Database Availability Group
DatabaseAvailabilityGroupServer
Get-MailboxServer
Retrieve Information about a Mailbox Server
Set-MailboxServer
Sets properties of a mailbox Server
Get-Queue
Retrieve information about the Transport Queue
Get-MessageTrackingLog
Retrieve information from the Message Tracking Log
Get-ExchangeServer
Retrieve information about the Exchange Servers in the Organization
Get-EventLogLevel
Retrieve information about Diagnostic Logging
Set-EventLogLevel
Set the properties for Diagnostic Logging
Examples
GetDatabaseAvailabilityGroup Identity DAG1
Retrieves information about the Database Availability Group DAG1
AddDatabaseAvailabilityGroupServer identity DAG1 MailboxServer Server2
Adds a server named Server2 to the Database Availability Group DAG1
SetEventLogLevel Identity MSExchangeFDS\FileReplication Level Expert
Sets the diagnostic logging to Expert level for the File Distribution Service\File Replication component

Useful PowerShell One Liners


GetMailboxDatabase | GetMailboxDatabaseCopyStatus
Displays the copy status for all Mailbox Databases in the Organization
GetDatabaseAvailabilityGroup Status | fl
Displays full information about the Database Availability Group including the Primary Active Manager and FSW
GetQueue Filter {MessageCount gt 100}
Shows any Transport queue with more than 100 messages in it. This can be used to identify a transport problem
GetDistributionGroupMember Senior Managers | SetMailbox prohibitSendRecieveQuota 2GB
Sets members of the Senior Managers Distribution List to have a Mailbox Quota of 2GB
NewDynamicDistributionGroup name Sales Team ConditionalDepartment Sales includedrecipients
Allrecipients
Creates a new Dynamic Distribution Group containing all users whos Department property is Sales
ForEach ($RoleEntry in GetManagementRoleEntry *\RemoveMailbox parameters Identity) {Get
ManagementRoleAssignment Role $RoleEntry.Role GetEffectiveUsers Delegating $False | WhereObject
{$_.EffectiveUserName Ne "All Group Members"} | FL Role, EffectiveUserName, AssignmentChain}
Retrieves a list of all users who can run the RemoveMailbox Cmdlet
GetMailbox | GetMailboxStatistics | Select Displayname,ItemCount,TotalItemSize,Database,StorageLimitStatus |
ConvertToHTML | OutFile MailboxInfo.html
Outputs Mailbox Statistic information to an HTML File
Function to display the emptiest Exchange Database (Based on number of users)
Function GetEmptiestMailbox{
$DBs = GetMailboxDatabase
$DBs | AddMember name Mailboxes Type ScriptProperty value {(Getmailbox database
$this.DistinguishedName).count}
$DBs = $DBs | SortObject Mailboxes descending
$DBs[1]
}
This can be used in Cmdlets such as NewMoveRequest TargetDatabase (GetEmptiestMailbox)

You might also like