Monday, August 22, 2016

Mail DB seed status

The team decided to build a new mail server and added it to the DAG.  As they were seeding the existing mail DBs to the new server I asked about the status.  One of the team members said you have to do this here and this there then subtract these two numbers.  I told him there has to be a better way.  Fifteen minutes later he came back with this:

$SERVER = "Your Mail Server"
$DB = "Your Mail DB"
(Get-MailboxDatabaseCopyStatus -Identity "$DB\$SERVER") | fl DatabaseSeedStatus, ContentIndexState, CopyQueueLength, StatusRetrievedTime

Output example:
DatabaseSeedStatus  : Percentage:90; Read:387.7 GB; Written:387.7 GB; ReadPerSec:4.727 MB; WrittenPerSec:4.726 MB
ContentIndexState   : FailedAndSuspended
CopyQueueLength     : 1295605

StatusRetrievedTime : 7/4/2016 1:45:04 PM

Monday, August 15, 2016

Re-balance mail DBs in a DAG

I ran into an issue where my mail DBs all ended up on one host in my DAG.  Being the DAG system was still new to me coming from Exchange 2007 SCC I had to get on google.  I found the script below that would inform me which MBX the activation preference was set to for each DB among other things.

Get-MailboxDatabaseCopyStatus * -Active | Select Name,Status,MailboxServer,ActivationPreference,ContentIndexState | Format-Table -AutoSize

Once I knew everything wasn’t set to all activate on the same host I looked for a way to rebalance my mail DBs across the hosts in my DAG.  That’s when I called a former employee and asked if knew a way and to make sure I was going down the right path.  He gave me this:

From Exchange Management Shell on one of your exchange servers:
cd '.\Program Files\Microsoft\Exchange Server\V15\Scripts'

Then run this:

.\RedistributeActiveDatabases.ps1 -DagName “Your DAG Name” -BalanceDbsByActivationPreference -confirm:$false –ShowFinalDatabaseDistribution


This process only takes 5 minutes or so but when it’s done your Mail DBs will be online living on its preferred host.

Monday, August 8, 2016

Exchange health scripts

When I got promoted into a leadership role years ago one of the first things I knew I need to give up was Exchange Administration.  There was no way I could effectively complete my new responsibilities and manage the health of Exchange long term.  So I hire a guy, he ended up being the most talented “mail guy” I have worked with.  This enabled me to walk away from exchange and sleep through the night.  Fast forward 4 years and I start a new job.  Not sure what type of talent I had, I knew I needed to monitor things from a distance and my confidence build for my new team.  I started with Exchange, things changed a lot from 2007 to 2013.  So I hit the inter-webbles and in doing so I found some Exchange commands that helped me out.  I thought I would share.

The first one I use was:

Get-MailboxDatabaseCopyStatus -Server “Your Mail Server” | Sort-Object name | Format-Table –AutoSize

This allowed me to see all of my mail DBs on one page and their health status.

The second one was:

Get-Queue -Server “Your Mail Server”

This script allows you to see the queues and their associated message counts.  I also figured out if you run this command for each of your mail servers you will see all of your queues across all of you servers in the same table.

Example:
Get-Queue -Server "Your Mail Server 1"; Get-Queue -Server “Your Mail Server 2”; Get-Queue -Server “Your Mail Server 3”

The third was:

Test-ReplicationHealth -Identity “Your Mail Server”

It checks for all necessary services, listeners, and processes needed to successfully replicate you mail DBs to other DAG members.
The last script is:

Test-ServiceHealth -Server “Your Mail Server”

This just verifies all the required services are running.


All 4 of these helped me understand how healthy my new mail setup was and how responsive my new staff was also.

Monday, August 1, 2016

Find member of based on job title

Here one I have no clue why I wrote it, in any event I thought I would share.  This script looks up all users with similar titles and documents every group they are a member of.  In environments where access is granted by a person’s job role this may come in handy to validate like job roles are in the same group, have the same access especially after adds/changes.

Start of script

Get-ADUser -filter { title -like "*Manager*" } | Select-Object samAccountName | foreach { (Get-ADUser $_.samAccountname –Properties MemberOf | Select-Object MemberOf).MemberOf | Out-File c:\temp\Member_of_Manager.txt }


End of script