Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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