Skip to content

Instantly share code, notes, and snippets.

@ykfq
Forked from bill-long/ClearMoveFlags.ps1
Created August 9, 2016 08:18
Show Gist options
  • Save ykfq/ef74970fe2f4d21555edc4b5c0319569 to your computer and use it in GitHub Desktop.
Save ykfq/ef74970fe2f4d21555edc4b5c0319569 to your computer and use it in GitHub Desktop.
$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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment