how to move a user in the active directory to another OU using service now, please help me. with one example

srinivassoma
Kilo Explorer

how to move a user in the active directory to another OU using service now orchestration, please help me. with one example

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Srinivas,



Consider user with samaccountname= tcook has ou as "OU=Non Employees,OU=Users,OU=Company,OU=India,DC=corporation,DC=Company,DC=com" and you want to move the user to following ou


"OU=Employees,OU=Users,OU=Company,OU=India,DC=corporation,DC=Company,DC=com"



Steps: Here you would require orchestration and powershell activities both to perform the actions


1) Use Update AD Object orchestration activity and update ou to new value


2) Fetch the objectGUID of the user using powershell activity. The powershell activity doesn't return the direct value. you will have to do manipulation to get the user guid. you will have to create your own powershell activity here. powershell command is Get-ADUser "${activityInput.samaccountname}" -Properties objectGUID


3) Use your custom powershell activity and use the move-adObject command. powershell command is Move-ADObject "${activityInput.userObjectGUID}" -TargetPath "${activityInput.ouValue}"



pass objectGUID as parameter to ${activityInput.userObjectGUID}


pass the new ou value



this will definitely work. I have followed the same approach and it worked for me.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Srinivas Soma,



I have the same issue. and i need your help.



At the moment, I have the samaccountname= GEN_ITOMTEST1


"CN=GEN_ITOMTEST1,OU=Users,OU=CSP,DC=emea,DC=ecm,DC=era"


and I want to move this user to : "CN=GEN_ITOMTEST1,OU=Users,OU=Disabled,DC=emea,DC=ecm,DC=era"



I use the steps that you define previousuly.



Step 1


Result OK


find_real_file.png



Step 2


Result OK


find_real_file.png




Step 3


Result KO, I have these error message:



"errorMessages": "Authentication failure with the local MID server service credential.\nFailed to access target system.   Please check credentials and firewall settings on the target system to ensure accessibility: ...."



Could tell me if all it's good in my configuration? I may have forgotten something!



Please find below my configuration:



Inputs


find_real_file.png


Execution command


find_real_file.png



Regards


Yanick


Hi Srinivas

 

I have tried this procedure but getting a below error. Can you please tell why this error is coming? When we ran the same command in AD, it worked fine.

 

The term 'Move-ADObject' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Stack Trace:    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

 

Please help.

 

Regards

Praveen

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Srinivas,



Did you give a try to the solution I mentioned in the above post?



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader