- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 08:32 AM
Afternoon all, I am trying to move a user to a different active directory OU on the execution of a flow (not workflow).
I can see there is a PSscript: ActionMoveADObjecttoOU.ps1
Has anyone managed to get this working for a user rather than a computer using the AD spoke? And if so, how did you achieve it?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 03:55 PM
To get this working i created a custom action using this PS script: In my set up, i have a table with all the OU's I need. then dynamically set it in my flow.
Create an action | ServiceNow Docs
if (test-path env:\SNC_username) {
$UserName = $env:SNC_username;
$OU = $env:SNC_OU;
};
try {
Get-ADUser -Identity "$UserName" | Move-ADObject -TargetPath "$OU"
Write-Host "SUCCESS: Moved $UserName to $OU"
}
catch {
$ErrorMessage = $_.Exception.Message
Write-Host "FAILED to move $UserName to $OU. Error message: $ErrorMessage"
}
Please mark helpful or correct 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 11:13 AM
A screenshot of the action would also be super helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 01:43 PM
We used oob action 'Update Object OU' to move the users to disabled OU in AD.
First we used 'Look up user' action in AD using Sam Account Name as the input.
Second we used 'Update Object OU'
For inputs:
1. Object - got the Distinguished Name of the user from the first action. This worked perfectly.
2. OU= whichever OU you want the user to be moved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 11:03 PM
Hi,
See below thread and check if that helps you in your requirement:
https://community.servicenow.com/community?id=community_question&sys_id=344cb214db0b2c50fb4ae15b8a961914
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2022 01:13 AM
Hi,
You can use an OOTB action for the same. "Update AD Object OU".
Input is samaccoutname (User ID) and OU path like "OU=Users,OU=San Diego,OU=USSites,DC=snownet,DC=snow,DC=intranet"
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 11:09 AM
Hi,
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
