/build/static/layout/Breadcrumb_cap_w.png

Moving Devices Automatically

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.


0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: Xnosis 1 year ago
White Belt
0

Top Answer

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}

Comments:

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
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