Orchestrator adding user to group

Jul 16, 2014 at 4:04 PM
Fairly simple idea...that's proving more troublesome then it looks.

I want to have a runbook that takes a list of users then adds them to a Group. Then periodically I'll re-run an updated list to add any new users.

The trouble is, I can find no simple way to exclude users who are already in the group. This means although the runbook itself works and new users are added, a number of warning messages are created for users who already exist (which I'm hoping to avoid). These warnings mean having to manually check each one just incase there is a genuine issue.
Oct 3, 2014 at 4:26 PM
Edited Oct 3, 2014 at 4:37 PM
Before the add users run a powershell script that filters through the list and finds already added users, and creates a temporary new list to feed your activity (nom nom nom)
#Filename eg users.txt
$filename = ""
#Directory path to file eg C:\users\documents
$Path = ""
out-file "$path\tempcreate.txt"
$Name = get-content $path\$filename
FOREACH($name in $name){
$User = Get-ADUser -LDAPFilter "(sAMAccountName=$Name)"
If ($User -eq $Null) {
Write-output $user | out-file "$path\tempcreate.txt" -append
Else {}
Put your $path\tempcreate.txt as the path to the user create, hope that helps!