Last active
October 2, 2018 22:46
-
-
Save jkbryan/24ce7a41172b028ac1ce6d59bacf29e3 to your computer and use it in GitHub Desktop.
clear-adou-attribute.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module LithnetRMA | |
# Setup the XPath Query - get all users | |
$z=New-XPathQuery -AttributeName AccountName -Operator IsPresent | |
# Use that query in the XPath Expression | |
$Query=New-XPathExpression -ObjectType Person -QueryObject $z | |
# Do the search | |
$Users=Search-Resources -XPath $query -AttributesToGet AccountName, adOU | |
ForEach ($u in $users) | |
{ | |
# If adOU is not NULL, then make it so! | |
If ($u.adOU -ne $NULL) | |
{ | |
$u.adOU=$NULL | |
Save-Resource $u | |
Write-Host $u.AccountName, $u.adOU | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment