Powershell Moving computer account to specified OU in AD server
Powershell Moving computer account to specified OU in AD server
#Importing AD Module
Write-Host " Importing AD Module..... "
import-module ActiveDirectory
Write-Host " Importing Move List..... "
# Reading list of computers from csv and loading into variable
$MoveList = Import-Csv -Path "C:\computers.csv"
# defining Target Path
$TargetOU = 'OU=Computers,OU=VA,DC=pugazh,DC=co,DC=in'
$countPC = ($movelist).count
Write-Host " Starting import computers ..."
foreach ($Computer in $MoveList){
Write-Host " Moving Computer Accounts..."
Get-ADComputer $Computer.CN | Move-ADObject -TargetPath $TargetOU
}
Write-Host " Completed Move List "
Write-Host " $countPC Computers has been moved "
#Importing AD Module
Write-Host " Importing AD Module..... "
import-module ActiveDirectory
Write-Host " Importing Move List..... "
# Reading list of computers from csv and loading into variable
$MoveList = Import-Csv -Path "C:\computers.csv"
# defining Target Path
$TargetOU = 'OU=Computers,OU=VA,DC=pugazh,DC=co,DC=in'
$countPC = ($movelist).count
Write-Host " Starting import computers ..."
foreach ($Computer in $MoveList){
Write-Host " Moving Computer Accounts..."
Get-ADComputer $Computer.CN | Move-ADObject -TargetPath $TargetOU
}
Write-Host " Completed Move List "
Write-Host " $countPC Computers has been moved "
Comments
Post a Comment