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:
Please log in to answer
Posted by:
Xnosis
4 years ago
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:
-
Works great, thank you! - moinahmed89 4 years ago