Skip to content

Instantly share code, notes, and snippets.

@RobinBeismann
Last active October 15, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinBeismann/c5879ebd21c54d4452f92b9adb5fad26 to your computer and use it in GitHub Desktop.
Save RobinBeismann/c5879ebd21c54d4452f92b9adb5fad26 to your computer and use it in GitHub Desktop.
Code Vorschlag
[regex]$regex = "(?:,)(?'name'((CN|OU=).*))"
Get-ADUser -Filter * -SearchBase "OU=Benutzer,DC=ad2016,DC=faq-o-matic,DC=net" | ForEach-Object {
$ou = $regex.Match($_.DistinguishedName).Groups['name']
Write-Host($_.Name + ": $ou")
$_ | Set-ADUser -Add @{info=$ou}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment