2013年8月25日 星期日

AD 依條件搬移ADComputer物件到指定的容器中

AD 依條件搬移ADComputer物件到指定的容器中

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Move-ADObject.ps1

Move-ADObject.ps1
Import-Module activedirectory
$target = Get-ADOrganizationalUnit -LDAPFilter "(name=用戶端電腦)"
Get-ADComputer -LDAPFilter "(name=CAR*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=PCS*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=OA*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=IPD*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=OPD*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=CR*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName

沒有留言:

張貼留言