Move the client host to the specified OU

Source: Internet
Author: User
Tags windows 10 enterprise

##########################################
###### #将客户端主机移动到指定的OU内 ######
################# V1.0 #################
############ Yuanzhe #################

# # #添加 ActiveDirectory Power Shell Module # # #
Import-module ActiveDirectory
# # #将Windows7 Enterprise Edition assigned variable # # #
# # # # # $windows 7enterpise=get-adcomputer-searchbase "cn=computers,dc=ljstaff,dc=com"-filter {operatingsystem-eq " Windows 7 Enterprise Edition "}-properties operatingsystem,operatingsystemversion | Select Operatingsystem,operatingsystemversion
$windows 7enterpise = "Windows 7 Enterprise Edition"

# # #将Windows7 The Ultimate version of the variable # # #
$windows 7uitimate= "Windows 7 flagship Edition"

# # #将Windows10 Enterprise Edition assigned variable # # #
$windows 10enterpise= "Windows 10 Enterprise Edition"

# # #将Windows 10 Pro version gives variable # # #
$windows 10professionaledition= "Windows 10 Pro"

# # #查看computers目录下的所有计算机 # #
$computers =get-adcomputer-searchbase "cn=computers,dc=windows,dc=com"-filter *-properties operatingsystem, operatingSystemVersion

# # #添加域主机的OU目录 # #
$dasou = "Ou=das,dc=windows,dc=com"

foreach ($lscomputer in $computers)
{
# # #将computers The Windows 7 Enterprise computer under the OU moves to the DAS ou # # #
if ($lscomputer. Operatingsystem-eq "$windows 7enterpise") {
Move-adobject-identity $lscomputer-targetpath $dasou
# # #暂停 # #
#Pause
}
# # #将computers The Windows 7 Ultimate computer under the OU moves to the DAS ou # # #
if ($lscomputer. Operatingsystem-eq "$windows 7Uitimate") {
Move-adobject-identity $lscomputer-targetpath $dasou
# # #暂停 # #
#Pause
}
# # #将computers The Windows 10 Enterprise computer under the OU moves to the DAS ou # # #
if ($lscomputer. Operatingsystem-eq "$windows 10Enterpise") {
Move-adobject-identity $lscomputer-targetpath $dasou
# # #暂停 # #
#Pause
}
# # #将computers The Windows 10 Professional computer under the OU moves to the DAS ou # # #
if ($lscomputer. Operatingsystem-eq "$windows 10ProfessionalEdition") {
Move-adobject-identity $lscomputer-targetpath $dasou
# # #暂停 # #
#Pause
}
}

Make a task plan

Run the script every 4 hours

Adding parameters
Program script: PowerShell #运行工具
Add parameter: C:\script\Movecomputer.ps1 #脚本路径
Starting from: C:\script\ #指定程序目录

Move the client host to the specified OU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.