Skip to content

Instantly share code, notes, and snippets.

@bill-long
Last active August 9, 2016 08:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bill-long/c17149291d3ab48e05bc3b1d48fb2c2d to your computer and use it in GitHub Desktop.
Save bill-long/c17149291d3ab48e05bc3b1d48fb2c2d 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