Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
clear-adou-attribute.ps1
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