Exchange 2013 Powershell commands

Get all mailboxes and SMTP addresses

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}

Get item counts of all mailbox folders

PS C:UsersfdoolingDesktop> Get-Mailbox -Identity USER | Get-MailboxFolderStatistics | Where {$_.Name -match “Inbox|Sent Items|Deleted Items|Junk E-Mail”} | Select Name, ItemsInFolder

Get all Public Folders and Owners

Get-PublicFolder -Identity “” -Recurse | Get-PublicFolderClientPermission | where{$_.Accessrights -eq “owner”}

DELEGATION

 

Grant user Joe full access to Bob mailbox

Add-MailboxPermission -Identity Bob -User Joe -AccessRights FullAccess -InheritanceType All

 

List all Users Who Have Access to Other Exchange Mailboxes

Get-Mailbox | Get-MailboxPermission | where {$_.user.tostring() -ne “NT AUTHORITYSELF” -and $_.IsInherited -eq $false} | Select Identity,User,@{Name=’Access Rights’;Expression={[string]::join(‘, ‘, $_.AccessRights)}} | Export-Csv -NoTypeInformation C:*location*mailboxpermissionssource.csv

Get mailbox forward to from mailboxes

Get-Mailbox -Filter {ForwardingAddress -ne $Null} |Select Alias, ForwardingAddress | Export-Csv -NoType -encoding “unicode” C:*location*MailboxesForwardTo.csv

Get mailbox grant send on behalf to

Get-Mailbox -Filter {GrantSendOnBehalfTo -ne $Null} |Select Alias, @{Name=’GrantSendOnBehalfTo’;Expression={[string]::join(“;”, ($_.GrantSendOnBehalfTo))}} | Export-Csv -NoType -encoding “unicode” C:*location*MailboxesSendOnBehalf.csv

Get mailbox accept messages only from senders or member

Get-Mailbox | Where-Object {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $Null} | Select Alias, @{Name=’AcceptMessagesOnlyFromSendersOrMembers’;Expression={[string]::join(“;”, ($_.AcceptMessagesOnlyFromSendersOrMembers))}} | Export-Csv -NoType -encoding “unicode” C:*location*MailboxesAcceptFrom.csv

Get mailbox reject messages from senders or members

Get-Mailbox | Where-Object {$_.RejectMessagesFromSendersOrMembers -ne $Null} | Select Alias, @{Name=’RejectMessagesFromSendersOrMembers’;Expression={[string]::join(“;”, ($_.RejectMessagesFromSendersOrMembers))}} | Export-Csv -NoType -encoding “unicode” C:*location*MailboxesRejectFrom.csv

Get Distribution group accept messages only from

Get-DistributionGroup | Where-Object {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $Null} | Select Alias, @{Name=’AcceptMessagesOnlyFromSendersOrMembers’;Expression={[string]::join(“;”, ($_.AcceptMessagesOnlyFromSendersOrMembers))}} | Export-Csv -NoType -encoding “unicode” C:*location*GroupsAcceptFrom.csv

Get Distribution group reject messages from sender or members

Get-DistributionGroup | Where-Object {$_.RejectMessagesFromSendersOrMembers -ne $Null} | Select Alias, @{Name=’RejectMessagesFromSendersOrMembers’;Expression={[string]::join(“;”, ($_.RejectMessagesFromSendersOrMembers))}} | Export-Csv -NoType -encoding “unicode” C:*location*GroupsRejectFrom.csv

ARCHIVING

Archive to pst

New-MailboxExportRequest -Mailbox USER -FilePath “\srvexchange01g$archivedb01USER.pst”

Import from pst

New-MailboxImportRequest -Mailbox USER -FilePath \srvexchange01g$archivedb01Recovered.pst –TargetRootFolder “RecoveredFiles” -IncludeFolders “#Inbox#”

PUBLIC FOLDERS

View all public folders

Get-PublicFolder -Recurse | Format-List Name

View public folder access permissions

Get-PublicFolderClientPermission -Identity “NAME” | fl

Give user Joe create items access

Add-PublicFolderClientPermission -Identity “My Public Folder” -User Chris -AccessRights CreateItems

MIGRATION COMMANDS

Moves one mailbox to a new database

New-MoveRequest -Id ALIAS -TargetDatabase MailboxDB01 -BadItemLimit 10

Get failure message for moves

Get-MoveRequest -MoveStatus Failed | Get-MoveRequestStatistics | ft Alias, percentcomplete, message -auto

Views quick details on all move requests

Get-moverequest | get-moverequeststatistics

Removes all completed move requests

Get-moverequest –movestatus completed | remove-moverequest

Gets data on one specific move request

get-moverequest -id ALIAS

Downloads report on a specific move request

Get-MoveRequestStatistics “Jane Doe” -IncludeReport | fl report

Suspends all in progress move requests

get-moverequest -movestatus inprogress | suspend-moverequest

TO FIX Fatal error TooManyBadItemsPermanentException has occurred

New-MoveRequest -Id ALIAS -TargetDatabase MailboxDB01 -BadItemLimit 100 –AcceptLargeDataLoss

MESSAGE TRACKING

Get message logs with start and end date

Get-MessageTrackingLog -Start “9/17/2012 00:00:00” -End “9/17/2012 11:59:59” -ResultSize unlimited

 

 

SQL REPORTING

Create throttling policy for sqlagent

New-ThrottlingPolicy -Name SQLAgent -EwsMaxConcurrency 20 -ThrottlingPolicyScope Regular

Add user to throttling policy

Set-ThrottlingPolicyAssociation -Identity sqlagent -ThrottlingPolicy SQLAgent

Increase receive connector throttling

Set-ReceiveConnector -identity “receive connector name” -MaxInboundConnectionPercentagePerSource 6 –MaxInboundConnectionPerSource 300 –MaxInboundConnection 5000

ACTIVESYNC

Get mobile device

Get-mobiledevice –mailbox ID

Remove mobile from Active Sync

Get-mobiledevice –mailbox ID | remove-mobiledevice (may have to do this more than once)

Get devices not synched in past 90 days

Get-MobileDevice -ResultSize unlimited | Get-MobileDeviceStatistics | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)}

Get devices not synched in past 90 days and remove them

Get-MobileDevice -ResultSize unlimited | Get-MobileDeviceStatistics | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)} | foreach-object {Remove-MobileDevice ([string]$_.Guid) -confirm:$false}

REPAIR MAILBOX

Detect and repair all corruption types

New-MailboxRepairRequest -Mailbox USER -CorruptionType ProvisionedFolder,SearchFolder,AggregateCounts,Folderview

MAILBOX CREATION/REMOVAL

Create mailbox for existing AD user

Enable-Mailbox user@email.com -Database UsersMailboxDatabase

Disable email account for user

Disable-mailbox user@email.com

NDR fix for legacy X500

Get-ADUser -Identity USER | Set-ADUser -add @{‘ProxyAddresses’=@(“X500:/O=company/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=3c480cf1d3dc4d8a83ebb8694dcba724-USER”)}

*This info is obtained from ADSI edit (KB: https://support.microsoft.com/en-us/kb/2807779)

Calendar

View user calendar permissions

Get-MailboxFolderPermission -identity “Firstname Lastname:Calendar”

Adding calendar permissions

Add-MailboxFolderPermission  -Identity user@email.com:Calendar –user personneedingaccess@email.com –accessrights Owner

DAG

Rebalance DAG (script is D:Program FilesMicrosoftExchangev15Scripts)

.RedistributeActiveDatabases.ps1 -DagName srvexchdag01 -BalanceDbsByActivationPreference -Confirm:$False

Default receive connectors

 

Name             : Default EX2013

AuthMechanism    : Tls, Integrated, BasicAuth, BasicAuthRequireTLS, ExchangeServer

RemoteIPRanges   : {0.0.0.0-255.255.255.255}

TransportRole    : HubTransport

PermissionGroups : ExchangeUsers, ExchangeServers, ExchangeLegacyServers

MaxMessageSize   : 35 MB (36,700,160 bytes)

Name             : Client Proxy EX2013

AuthMechanism    : Tls, Integrated, BasicAuth, BasicAuthRequireTLS, ExchangeServer

RemoteIPRanges   : {0.0.0.0-255.255.255.255}

TransportRole    : HubTransport

PermissionGroups : ExchangeUsers, ExchangeServers

MaxMessageSize   : 35 MB (36,700,160 bytes)

Name             : Default Frontend EX2013

AuthMechanism    : Tls, Integrated, BasicAuth, BasicAuthRequireTLS, ExchangeServer

RemoteIPRanges   : { 0.0.0.0-255.255.255.255}

TransportRole    : FrontendTransport

PermissionGroups : AnonymousUsers, ExchangeServers, ExchangeLegacyServers

MaxMessageSize   : 36 MB (37,748,736 bytes)

Name             : Outbound Proxy Frontend EX2013

AuthMechanism    : Tls, Integrated, BasicAuth, BasicAuthRequireTLS, ExchangeServer

RemoteIPRanges   : { 0.0.0.0-255.255.255.255}

TransportRole    : FrontendTransport

PermissionGroups : AnonymousUsers, ExchangeServers

MaxMessageSize   : 36 MB (37,748,736 bytes)

Name             : Client Frontend EX2013

AuthMechanism    : Tls, Integrated, BasicAuth, BasicAuthRequireTLS

RemoteIPRanges   : {0.0.0.0-255.255.255.255}

TransportRole    : FrontendTransport

PermissionGroups : ExchangeUsers

MaxMessageSize   : 35 MB (36,700,160 bytes)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s