filmov
tv
Move Disabled computers in OU with powershell | Move all disabled computers in disabled computers OU

Показать описание
In this video I have Used a powershell script for moving all disabled computers in Inactive computers OU. This script will create a powershell graphical interface and show you all disabled computers and Target OU unit where you want to move. Below is the script. You have to change the domain distinguished name of your domain and create inactive computers or disabled computers ou accordingly.
$ADComps= Get-ADComputer -Filter "Enabled -eq 'False'" -SearchBase "DC=infoalias,DC=local"| Select-Object -Property Name |sort -Property name | Out-GridView -PassThru –title “Select Computers to Move”| Select -ExpandProperty Name
$ADOUs= Get-ADOrganizationalUnit -Filter * | Select-Object -Property DistinguishedName | Out-GridView -PassThru –title “Select Target OU”| Select-Object -ExpandProperty DistinguishedName
Foreach($ou in $ADOUs){
Foreach($comp in $ADComps){
get-adcomputer $comp |Move-ADObject -TargetPath "$ou" -Verbose }
}
$ADComps= Get-ADComputer -Filter "Enabled -eq 'False'" -SearchBase "DC=infoalias,DC=local"| Select-Object -Property Name |sort -Property name | Out-GridView -PassThru –title “Select Computers to Move”| Select -ExpandProperty Name
$ADOUs= Get-ADOrganizationalUnit -Filter * | Select-Object -Property DistinguishedName | Out-GridView -PassThru –title “Select Target OU”| Select-Object -ExpandProperty DistinguishedName
Foreach($ou in $ADOUs){
Foreach($comp in $ADComps){
get-adcomputer $comp |Move-ADObject -TargetPath "$ou" -Verbose }
}