Scripting Question

Moving Devices Automatically

12/19/2019 328 views


I need some help in creating a script which will move all devices from one OU to another OU after 1 week of domain join. 

Please assist.

Thank you in advance.

Answer Summary:
0 Comments   [ + ] Show comments


Answer Chosen by the Author


The command below should work as described. You would need to modify the variables as named before using.

$Date = [DateTime]::Today.AddDays(-7)
Get-ADComputer -Filter 'Created -le $Date' -Properties Created -SearchBase $CurrentOU | foreach {Move-ADObject -Identity $_.ObjectGUID -TargetPath $DestinationOU}
Answered 12/24/2019 by: Xnosis
White Belt