Working with Disconnected Mailboxes using powershell

To display mailboxes that are disconnected use the following command.
Get-MailboxStatistics -Server <server> | where { $_.DisconnectDate -ne $null } | select DisplayName,DisconnectDate
Replace <server> with the name of your mailbox server.
This gives a list of the disconnected mailboxes.
To reconnect you use the command below
Connect-mailbox –database <mailbox database name> –Identity <disconnected mailbox name> –User <User to connect to>
 The command below gives list of disconnected mailboxes on a server called Server1
Get-MailboxStatistics -Server “Server1” | where { $_.DisconnectDate -ne $null } | select DisplayName,DisconnectDate

some message tracking powershell commands for hub transport servers

some message tracking powershell commands for hub transport servers
Set-TransportServer “servername” –MessageTrackingLogMaxDirectorySize 2GB
Set-TransportServer E2K7 –MessageTrackingLogMaxFileSize 5MB
Set-TransportServer SERVERNAME –MessageTrackingLogMaxAge DD.HH:MM:SS
for eg Set-TransportServer E2K7 –MessageTrackingLogMaxAge 15.00:00:00
get-messagetrackinglog -Server “servername” -Start “1/14/2009 11:20:00 AM” -End “2/10/2009 11:20:00 AM” -resultsize unlimited | select timestamp, eventid, source, messagesubject, sender, internalmessageid, {_.recipients}, sourcecontext | export-csv c:msgtrakcsv

creating report of all exchange mailboxes with associated information

steps to create report of all exchange user mailboxes with associated Names, server names, departments and title
 
(Note, you must have at least exchange recipient management rights to do this)
1. Open Exchange management shell
2. Run the Get mailbox powershell command(see below)
3. Run the Get-user command (see pshell command below). Note that this can take up to 10-15minutes to complete
4. Open MS Access and open the text files to a database and import the text files to respective tables in same database
5. While importing, use fixed width. Name the fields. Choose no primary key
6. After importing, create join between required tables
7. Run query on joined tables

get-mailbox  -ResultSize Unlimited  | ft SamAccountName, DisplayName, ServerName | out-file c:all-EMTmboxes060309.txt
get-user  -ResultSize Unlimited | where-object{$_.RecipientType –eq “UserMailbox”}| ft SamAccountName, FirstName, LastName, Department, Title | out-file c:allusermailboxes060309.txt

Message Tracking vs SMTP Protcol Logging in Exchange 2007

Message tracking
 Is a feature that you can use to track messages across an Exchange organization. You can track all types of messages, including system messages and regular e-mail messages that are going to or coming from a non-Exchange messaging system. You can use Message Tracking Center to locate messages that failed to arrive in your users’ mailboxes, such as messages that are stuck in the message queue.
Message tracking is enabled by default in exchange 2007. You can modify the length of time log files are kept and increase logs directory size. The default period that tracking logs are kept is 30 days.
Protocol Logging
When you keep a history of all SMTP protocol activities, you can prove whether a particular message left your server, verify whether the SMTP virtual server is performing its work as expected or is experiencing communication problems, and identify attacks from the Internet.
Protocol Logging isn’t enabled by default on exchange 2007. Logging needs to be configured for the send and receive connectors. You can modify the length of time log files are kept and increase logs directory size. Default age period is set to 30days, but can be increased.