Sunday, November 25, 2012

Exchange Powershell Scripts for Daily Use

Hi Readers,

Today I am sharing spome small scripts that you can use for daily exchange operations:-

Clean Datbase so that mailboxes appears in disconnected state:

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

Get-MailboxServer | Get-MailboxDatabase | Clean-MailboxDatabase

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

Find Disconnected Mailboxes:

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

Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}}

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

Clustered Mailbox Status:

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

Get-ExchangeServer | where {$_.ServerRole -eq "Mailbox" -and $_.Edition –eq “Enterprise"} | Get-ClusteredMailboxServerStatus

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

Message Tracking :

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

Get-transportserver | Get-MessageTrackingLog -Start "8/17/2012 12:00:00 AM" -End "8/24/2012 11:49:59 PM"  -resultsize unlimited | where { $_.sender -like  “xxxxxx@xxxxxx.com”  –or  $_.recipients -like  xxxxxx@xxxxxx.com”} | select Timestamp,clientip,ClientHostname,ServerIp,ServerHostname,sender, EventId,MessageSubject,@{Name=”Recipents”;Expression={$_.recipients}} | export-csv c:\track.csv

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

extract Message accept from:

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

Get-distributiongroup "dl name" | % { $_.AcceptMessagesonlyFrom} | add-content  "c:/output/abc.txt"

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

Active Sync Stats

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

Get-CASMailbox -ResultSize unlimited | where {$_.ActiveSyncEnabled -eq "true"} | ForEach-Object {Get-ActiveSyncDeviceStatistics -Mailbox:$_.identity} | select Devicetype, DeviceID,DeviceUserAgent, FirstSyncTime, LastSuccessSync, Identity, DeviceModel, DeviceFriendlyName, DeviceOS | Export-Csv c:\activesync.csv

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

Regards

Sukhija Vikas

1 comment:

  1. Good day! I just would like to give a huge thumbs up for the nice info you may have here on this post. I will likely be coming again to your blog for more soon.

    ReplyDelete