Last active
October 15, 2017 22:46
-
-
Save RobinBeismann/c5879ebd21c54d4452f92b9adb5fad26 to your computer and use it in GitHub Desktop.
Code Vorschlag
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
[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