Add user to Ad group

Brian Lancaster
Tera Sage

I have a requirement to add users to AD groups via ServiceNow Orchestration.   What is the best way to do this?   I thought it would be update AD object but i'm note sure what to put in Object data field.

18 REPLIES 18

Do you have multiple domains?   What does that data in your array look like?


I am using this code for single user


Import-Module ActiveDirectory


$GrpName = "${workflow.scratchpad.GrpName}"


$DLMem = Get-ADUser -identity ${workflow.scratchpad.userSAM}


Get-AdGroup -identity $GrpName | Add-ADGroupMember -Members $DLMem   -Confirm:$false -credential $cred



Now i need to add the users in array "user1, user2, user3,user4," to AD group.



how to loop them in Power shell.


I spoke with our powershell guru and he said he was able to do a direct powershell script like below but he do not have anything like this in our servicenow environment so I'm not sure how it would translate.


set-adobject "group"
-Add @{ member = @('user1','user2') }



note the @() for the array notation.


Brian,



I think i have given wrong information. My actual requirement is:



There is a catalog request which a requester can give many user names (List Collector variable) and a group name in the Item. After all approvals


using orchestration i need to add those users to the group in AD.


I have made a string with all user names from the request separated by ",".


I need power Shell scripting to add those users to the group. Help me with the script.



Thanks


Shiva


that is what I gave you.