/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Moving Devices Automatically

12/19/2019 565 views

Hi,

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

Comments


Answer Chosen by the Author

0

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


$Date = [DateTime]::Today.AddDays(-7)
$CurrentOU = 'DISTINGUISHEDNAMEOFOU'
$DestinationOU = 'DISTINGUISHEDNAMEOFOU'
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

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ