Friday, October 7, 2011

Exchange 2010 - PowerShell Commands

Restart Exchange Services

Get-Service | ? { $_.name -like "MSExchange*" -and $_.Status -eq "Running"} foreach ($service in $services) {Restart-Service $service.name -Force}


Get-wmiobject win32_service | ? {$_.name -like "MSExchange*" -and $_.StartMode -eq "Auto"} foreach ($service in $services) {Restart-Service $service.name -Force}

##########################################################################################################################################################################################3

Get-service -name "msexchange*" -dependentservices Where-Object {$_.Status -eq 'Running'} Stop-Service

Starting all exchange services could be done by following code:

Get-service -name "msexchange*" start-service

get-service -name "msexchange*" -DependentServices -exclude msexchangepop3,msexchangeimap4,msexchangeMonitoring start-service

In which we would query the services and only start services which have been set to start automatically.

Get-Service -name "msexchange*" where-object {$_.startuptype -eq "automatic"} start-service



Get-Service | Where {$_.DisplayName -Like "Microsoft Exchange*"}

=======================================================

Update OAB on Client Access Server
1. Restart "MS Exchange System Attendant Service" on (Mailbox Server)

2. Update-FileDistributionService -Identity my-cas-server-host-name -Type OAB

Testing Commands

test-mailflow your-mailbox-server -TargetEmailAddress zawhtet@mmx.com
test-servicehealth <-- check whether require services are running or not!
test-mapiconnectivity
test-outlookconnectivity

Monitoring Mail Queue and Messages
get-message
get-queue

Message Tracking and Export to HTML file

Get-MessageTrackingLog -EventID Deliver/Fail -Sender "Fazana@gmail.com" -Recipients "sandi@mmx.com" -Start 10/3/2011 -End 10/4/2011 | ConvertTo-Html Timestamp, ClientIp, EventID, Sender, {$_.Recipients}, TotalBytes, RecipientCount, MessageSubject | Set-Content c:\sandi.html

get-messagetrackinglog -EventID Fail -start "1/20/2011 12:00am" -resultsize 3000| where {[string]$_.recipients -like "*@gmail.com"}

Get-MessageTrackingLog -resultsize unlimited |where-object {$_.Recipients -like "*@gmail.com, *@yahoo.com" -AND $_.EventId -eq "Send"} |ft -auto >>d:\external.txt

get-transportserver | Get-MessageTrackingLog -ResultSize Unlimited -Start “10/17/2009 8:00AM” -End “11/17/2009 5:00PM” -eventid Send | WHERE {$_.recipients -like “*domainname.com*”} > “c:\send.xls”

If you found that mail flow for your Server is slow

Get_receiveConnector

Set-ReceiveConnector "your receive connector name" -MaxAcknowledgementDelay 0

Set your transport Connector to Send and Receive 20MB Emails

Set-TransportServer your-cas-svr -MaxConcurrentMailboxDeliveries 20

Get-TransportConfig
Get-TransportConfig | fl MaxSendSize,MaxReceiveSize
Set-TransportConfig -MaxReceiveSize 20MB -MaxSendSize 20MB

Get-Adsitelink DEFAULTIPSITELINK | select Maxmessagesize
Set-Adsitelink DEFAULTIPSITELINK -MaxMessageSize 20MB

Get-SendConnector
Get-Sendconnector "InternetSendConnector" | fl Name,MaxMessageSize
Set-Sendconnector "InternetSendConnector" -MaxMessageSize 20MB

Get-Receiveconnector
Get-Receiveconnector -Identity "" | fl Name,MaxMessagesize
Set-ReceiveConnector -Identity " -MaxMessageSize 20MB

Get-Mailbox zawhtet | fl MaxSendSize,MaxReceiveSize
Set-Mailbox Zaw Htet -MaxSendSize 20MB -MaxReceiveSize 20MB

Get-ForeignConnector | fl Name,MaxMessageSize
Get-SendConnector | fl Name,MaxMessageSize
Get-ReceiveConnector | fl Name,MaxMessageSize

Set Individual User's Mailbox (Send / Receive Message Size)

Get-Mailbox zaw Htet | Format-Table Name, *Max*

Set-Mailbox zaw Htet -MaxSendSize 20mb -MaxReceiveSize 20mb

Get and Set Room Mailbox to auto accept

get-Mailbox | where {$_.ResourceType -eq "Room"} | Set-MailboxCalendarConfiguration -AutomateProcessing:AutoAccept

Anti-Spam Configuration

Add-IPBlockListProvider -Name "SpamHaus IP Block List Provider" -LookupDomain "zen.spamhaus.org" -BitMaskMatch 127.0.0.1

Set-IPBlockListProvider "SpamHaus IP Block List Provider" -RejectionResponse "Your message was rejected because the IP address of the server sending your message is in the block list of SpamHaus IP Block List Provider service."

Get-IPBlockListProvider | Test-IPBlockListProvider -IPAddress xx.xx.xx.xx

Misc CMDs

Get-MailboxStatistics zawhtet | fl totalitemsize

Get-Mailbox zawhtet | fl *Quota

Update-GlobalAddressList -Identity "Default Global Adress List" -DomainController

Update-OfflineAddressBook “Name of Address Book”

Get-OfflineAddressBook | Update-OfflineAddressBook

Get-ReceiveConnector | fl Id*,Pr*

Get-SendConnector | fl Id*,Pr*

Get-TransportServer | fl Id*,*pro*log*

Get-MessageTrackingLog | fl

Remove-Message -Filter {FromAddress -like "*spammer.com*" -and SCL -gt 5} -withNDR $false

Remove-Message -Filter {FromAddress -like "*dorofej.com*" -and SCL -gt 7} -withNDR $false

Remove-Message -Server your-cas-svr.mmx.com -Filter {FromAddress -eq "zawhtet@mmx.com"} -WithNDR $false

Get-Queue -Filter {MessageCount -gt 100}

Get-Queue -Identity your-cas-svr.mmx.com\mmx.com | Format-List

Get-TransportServer your-cas-svr | fl

Get-MailboxServer your-mb1-svr | fl

nslookup

set q=mx
mail.mmx.com

This command will set the default warning quota on the database Mailbox Database on server your-mb1-svr to 975MB, and the limit at which users will no longer be able to send mail to 1000MB:

Set-MailboxDatabase your-mb1-svr\Mailbox Database -IssueWarningQuota 975MB -ProhibitSendQuota 1000MB

This command will set the warning quota for user zawhtet to 1475MB, and the limit at which the user will no longer be able to send mail to 1500MB. It will also configure the mailbox not to use the database default quotas:

Set-Mailbox zawhtet -IssueWarningQuota 1475MB -ProhibitSendQuota 1500MB -UseDatabaseQuotaDefaults $false


Command to list all messages to a specific domain for the day


get-transportserver | Get-MessageTrackingLog -ResultSize Unlimited -Start "10/29/2009 8:00AM" -End "10/29/2009 5:00PM" -eventid Send | WHERE {$_.recipients -like "*gmail.com*"} > "c:\gmail.xls"

Get-MessageTrackingLog -ResultSize Unlimited -Start “10/29/2010 8:00AM” -End “10/29/2010 5:00PM” -eventid Send | WHERE {$_.recipients -like “*gmail.com*”}

Get-Message -Filter {FromAddress -like "*@gmail.com"} | Format-List

Roles

New-ManagementRoleAssignment -Role "Message Tracking" -SecurityGroup "Exchange Message Tracking Access"
New-ManagementRoleAssignment -Role "View-Only Recipients" -SecurityGroup "Exchange Message Tracking Access"

New-ManagementRoleAssignment -Role "Message Tracking" -User zawhtet
New-ManagementRoleAssignment -Role "View-Only Recipients" -User zawhtet

Set-OrganizationConfig -ReadTrackingEnabled $true
Set-Mailbox zawhtet -MessageTrackingReadStatusEnabled $true
Get-OrganizationConfig | fl *read*

test-mailflow
test-servicehealth
test-mapiconnectivity
test-outlookconnectivity
get-mailboxstatistics -server your-mb-svr
get-mailboxstatistics -identity zawhtet
get-mailboxdatabase
get-transportpipeline
Get-ExchangeServer | Format-Table Name, *Version*
Get-ExchangeServer | Format-Table Name, Edition
Get-ExchangeServer -Status | Format-List
Get-ADSite
Get-ADSiteLink
Get-RoutingGroupConnector
Get-RoutingGroupConnector | ft Name,Cost
Set-RoutingGroupConnector -Identity “\\” -Cost 1
Get-offlineaddressbook | fl

Get-Mailbox -resultsize unlimited | Set-CasMailbox -ActiveSyncEnabled:$false

Get-User -OrganizationalUnit "mmx"


Get-WebServicesVirtualDirectory | fl
Get-AutodiscoverVirtualDirectory | fl
Get-OfflineAddressBook | fl
Get-OabVirtualDirectory | fl
Get-OabVirtualDirectory OAB* | fl

Get-ForeignConnector | fl Name,MaxMessageSize
Get-SendConnector | fl Name,MaxMessageSize
Get-ReceiveConnector | fl Name,MaxMessageSize
Get-ADSiteLink | fl Name,MaxMessageSize
Get-RoutingGroupConnector | fl Name,MaxMessageSize
Get-TransportConfig | fl MaxSendSize,MaxReceiveSize
Get-DistributionGroup | fl name,MaxSendSize,MaxReceiveSize
Get-DynamicDistributionGroup | fl name,MaxSendSize,MaxReceiveSize
Get-Mailbox | fl name,MaxSendSize,MaxReceiveSize
Get-MailContact | fl name,MaxSendSize,MaxReceiveSize
Get-MailPublicFolder | fl name,MaxSendSize,MaxReceiveSize
Get-MailUser | fl name,MaxSendSize,MaxReceiveSize

get-transportconfig | fl *

Get-AddressList | Update-Adresslist

set-transportserver you-cas-svr -ExternalPostMasterAddress spamfilter@mmx.com

set-transportconfig -externalpostmasteraddress spamfilter@mmx.com

set-OfflineAddressBook -Identity "Default Offline Address Book" -GlobalWebDistributionEnabled $true


-------------------------------------------------------------------------------------------------------------


TOP 10: Exchange Server 2010 PowerShell Commands

Here you will find a collection of the most commonly used commands I run in Exchange 2010. Enjoy!

1. Check Database Availability Group Replication Status
In some cases you may have many copies of Exchange 2010 databases and you want to view the status of them all. This command will perform that task for you but also show you a very important characteristic such as the content index state.

Get-MailboxDatabaseCopyStatus

2. Fix a Failed Content Index
In rare cases you may notice the content index has failed. Activating a database copy with a failed content index requires additional guidance but to fix the problem beforehand, run the following.

Update-MailboxDatabaseCopy -Identity [id] -CatalogOnly

3. Move a Mailbox in a Batch
There may be cases where you need to keep track of mailbox moves both those which are in progress and to clear them afterward.

New-MoveRequest -Identity [id] -BatchName

4. Check Move Progress
The following command simply gets all the move requests and their statistics.

Get-MoveRequest | Get-MoveRequestStatistics

4. Clear a Move Request
In order to move a mailbox after a move request has completed or failed, you need to remove the request which can be done in bulk, individually, or by a batch name.

Get-MoveRequest | Remove-MoveRequest

or to remove a batch of requests already labeled...

Get-MoveRequest -BatchName [name] | Remove-MoveRequest

5. Determine Unified Messaging Enablement of a User
To check if a user is enabled for Unified Messaging, run the following.

Get-Mailbox | fl UME*

6. View Queues of all Hub Transport Servers
In some cases you may want to quickly view the queue status of all HT servers to determine if you have significant blockage along the transport pipeline.

Get-TransportServer | Get-Queue

7. Determine Active Calls on a UM Server
I find this one helpful as you can quickly see if a server is in use before performing a UM service reset or else use it for troubleshooting to see the status of a test call.

Get-UmServer | Get-UMActiveCalls

8. Determine Exchange Server 2010 Service Status
This command is helpful in quickly seeing which services are running particularly after a reboot.

Get-Service | Where {$_.DisplayName -Like "Microsoft Exchange*"}

9. Get Mailbox Sizes and Sort by Size

Get-Mailbox | Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto

10. Check Autodiscover Settings

Get-WebServicesVirtualDirectory | fl InternalUrl,ExternalUrl
Get-EcpVirtualDirectory | fl InternalUrl,ExternalUrl
Get-OwaVirtualDirectory | fl InternalUrl,ExternalUrl
Get-OabVirtualDirectory | fl InternalUrl,ExternalUrl

Get-ClientAccessServer | fl AutoDiscoverServiceInternalUri

---------------------------------------------------------------

Get-Queue -id Submission | Get-Message | Remove-Message -WithNDR $false

Retry-Queue Submission -Resubmit $true

---------------------------------------------------------------------

How to clear corrupted Messages from the Hub or Edge Submission Queues

If you have ever tried to delete messages stuck in an overflowing Exchange 2007 submission queue you will notice that you can not simply delete the messages as you can for other queues.
In order to clear the Exchange 2007 submission queue you will have to create a new queue database from scratch. This may cause some mail loss but will allow you to get your mail queues functioning properly again.
First you need to be member of the apropriate Security Groups: Local Administrator for Edge Transport Server and Local Administrator+Server Administrator for Hub Transport Server.

Step 1 Stop the Microsoft Exchange Transport service like this:
Computer Management -->Services-->Locate and stop the Microsoft Exchange Transport Service
or from Exchange Managemet Shell type: Stop-Service MSExchangeTransport

Step 2 Navigate to the Queue folder location. By default the folder is located here:
C:\Program Files\Microsoft\Exchange Server\Transport Roles\Data\
Here you will find a folder named Queue .Rename this folder give it a name like Queue2.Create a new empty folder named Queue.

Step3 start the Microsoft Exchange Transport service like this:
Computer Management -->Services-->Locate and start the Microsoft Exchange Transport Service
or from Exchange Managemet Shell type: Start-Service MSExchangeTransport
Confirm mail flows both inbound and out of your server.(In other words the messages from the queues are disappearing.)
--------------------------------------------------------------

Add Position Email Account and Send As in "Outlook"

Add-MailboxPermission -Identity "IT Support" -User "Zaw Htet" -AccessRights FullAccess -InheritanceType All

Add-ADPermission -Identity "IT Support" -User "Zaw Htet" -AccessRights ExtendedRight -ExtendedRights "Send As" 
 


--------------------------------------------------------------
Get-IPBlockListProvider | Test-IPBlockListProvider -IPAddress 24.167.247.129 
--------------------------------------------------------------

Select top 30 mailboxes by totalitemsize

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,TotalItemSize -First 30 


C:\>Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | 
Sort-Object TotalItemSize -Descending | 
Select-Object DisplayName,TotalItemSize -First 100 | Export-CSV top100mailboxes.csv
 

31 comments:

Anonymous said...

xanax buy red xanax pills - xanax xr 1mg high

Anonymous said...

buy tramadol online tramadol hcl prescribed - tramadol withdrawal how long does it last

Anonymous said...

generic xanax 6mg xanax high - xanax bars withdrawals

Anonymous said...

buy tramadol online tramadol generic for ultram - tramadol 50 mg veterinary use

Anonymous said...

xanax xanax .5 side effects - xanax effects if not prescribed

Anonymous said...

buy tramadol online tramadol ultram same - tramadol 50 mg is equal to

Anonymous said...

buy carisoprodol carisoprodol 350 mg expired - carisoprodol common side effects

Anonymous said...

generic xanax order xanax online canada - much does generic xanax cost walmart

Anonymous said...

buy cheap tramadol buy tramadol 180 - tramadol trade name generic name

Anonymous said...

buy carisoprodol can get high carisoprodol - soma carisoprodol tablets 250 mg reviews

Anonymous said...

buy tramadol online tramadol 99 free shipping - tramadol dosage use dogs

Anonymous said...

buy tramadol online taking 100mg tramadol - best place buy tramadol tk

Anonymous said...

buy tramadol online illegal buy tramadol online usa - tramadol online no prescription needed

Anonymous said...

buy cialis online cialis slogan - cialis 20mg online

Anonymous said...

buy tramadol online tramadol purchase online no prescription - tramadol for dogs how much

Anonymous said...

buy cialis online cialis online thailand - is cialis daily covered by insurance

Anonymous said...

order cialis online canada generic cialis release date - cialis online drugs

Anonymous said...

http://landvoicelearning.com/#57594 tramadol dosage 60 lb dog - buy tramadol online us

Anonymous said...

buy tramadol tramadol 50mg for animals - buy tramadol cod online

Anonymous said...

buy tramadol cheap online tramadol hcl acetaminophen par - tramadol ultram addiction

Anonymous said...

tramadol 50 tramadol good withdrawal - buy tramadol online from usa

Anonymous said...

http://blog.dawn.com/dblog/buy/#38179 trusted online pharmacy tramadol - buy tramadol online missouri

Anonymous said...

buy generic tramadol cheapest generic tramadol - tramadol online no prescription cod

Anonymous said...

buy tramadol buy tramadol online from usa - buy tramadol 100mg online

Anonymous said...

buy tramadol tramadol ultracet dosage - tramadol hydrochloride 100 mg

Anonymous said...

buy tramadol gabapentin and tramadol for dogs - tramadol 100 mg ldt

Anonymous said...

buy tramadol with mastercard tramadol online paypal - tramadol no prescription free delivery

Anonymous said...

ways to buy ativan online ativan classification - ativan withdrawal in neonates

Anonymous said...

ativan pharmacy ativan withdrawal death - ativan side effects benefits

Anonymous said...

Hello There. I found your blog using msn. This is an extremely well written article.
I will be sure to bookmark it and return to read more of your useful information.
Thanks for the post. I will certainly comeback.

Feel free to surf to my site :: InstaForex

Anonymous said...

Heya! I'm at work surfing around your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the great work!

My site how can i get laid