Friday, September 19, 2014

Exchange Group Team Blog: Find Exchange Databases using Powershell

A small change in $strFilter=”(objectClass=msExchPrivateMDB)” and you get all the mailbox databases ;-)










$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$Dom = "LDAP://CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=" + $Forest.Name.Replace(".",",DC=")
$strFilter="(objectClass=msExchPrivateMDB)"
$Root = New-Object DirectoryServices.DirectoryEntry $Dom
$selector = New-Object DirectoryServices.DirectorySearcher
$selector.PageSize = 1000
$selector.Filter = $strFilter
$selector.SearchRoot = $root
$selector.SearchScope = "Subtree"
$Objs = $selector.findall()
$Objs.count
$Objs







from Exchange News Full Article

No comments:

Post a Comment