Share via


Active Directory-Move Inactive Computers to Specific Ou

**Using this script we can move the inactive Computers(User have to mentioned the time period) to the specific OU called Incomputers.
**

<#Before run this script need to create an organizational unit called InComputers,All the inactive computers will be moved to this OU using this script

#>

 

$strdomainname=(Get-ADDomain).DistinguishedName

$strdisname="OU=incomputers,"+$strdomainname

$Itime

$Itime=Read-Host "Enter the time of inactive time period by dates(ex 90)"

Write-Host $ltime

Write-Host $strdisname

Search-ADAccount -ComputersOnly -AccountInactive -TimeSpan $Itime|Move-ADObject -TargetPath $strdisname