ykfq
8/9/2016 - 8:18 AM

ClearMoveFlags.ps1

$searcher = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().FindGlobalCatalog()
$searcher.Filter = "(&(objectClass=user)(msExchMailboxMoveFlags=10))"
$results = $searcher.FindAll()
"Found " + $results.Count.ToString() + " results:"
foreach ($result in $results)
{
    $dn = $result.Properties["distinguishedName"][0].ToString()
    $dn
    $entry = [ADSI]("LDAP://" + $dn)
    $entry.Properties["msExchMailboxMoveFlags"].Clear()
    $entry.CommitChanges()
}