将客户端主机移动到指定的或者内

  

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # #将客户端主机移动到指定的或者内# # # # # #
# # # # # # # # # # # # # # # # # V1.0 # # # # # # # # # # # # # # # # #
# # # # # # # # # # # #李远哲# # # # # # # # # # # # # # # # #

  

# # #添加ActiveDirectory权力壳模块# # #
Import-Module ActiveDirectory
# # #将Windows7多企业版赋予变量# # #
# # # # $ windows7enterpise=Get-ADComputer -SearchBase“CN=电脑,DC=ljstaff, DC=com"Windows 7操作系统过滤器{eq“企业版“}属性操作,OperatingSystemVersion |选择操作,OperatingSystemVersion
$ windows7enterpise=癢indows 7的企业版“

  

# # #将Windows7多旗舰版赋予变量# # #
$ windows7Uitimate=癢indows 7旗舰版“

  

# # #将Windows10企业版版赋予变量# # #
$ windows10Enterpise=癢indows 10企业版“

  

# # #将Windows 10专业版版赋予变量# # #
$ windows10ProfessionalEdition=癢indows 10专业版“

  

# # #查看电脑目录下的所有计算机# # #
$计算机=Get-ADComputer -SearchBase“CN=电脑,DC=windows, DC=com"过滤器*操作系统属性,OperatingSystemVersion

  

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

  

foreach (lscomputer在电脑美元)
{
# # #将电脑或者下的Windows 7的企业版计算机移动到DAS OU内# # #
如果lscomputer美元。操作系统eq“windows7enterpise"美元){
Move-ADObject身份lscomputer美元美元定位路径dasou
# # #暂停# # #
#暂停
}
# # #将电脑或者下的Windows 7旗舰版计算机移动到DAS OU内# # #
如果lscomputer美元。操作系统eq“windows7Uitimate"美元){
Move-ADObject身份lscomputer美元美元定位路径dasou
# # #暂停# # #
#暂停
}
# # #将电脑或者下的Windows 10企业版计算机移动到DAS OU内# # #
如果lscomputer美元。操作系统eq“windows10Enterpise"美元){
Move-ADObject身份lscomputer美元美元定位路径dasou
# # #暂停# # #
#暂停
}
# # #将电脑或者下的Windows 10专业版计算机移动到DAS OU内# # #
如果lscomputer美元。操作系统eq“windows10ProfessionalEdition"美元){
Move-ADObject身份lscomputer美元美元定位路径dasou
# # #暂停# # #
#暂停
}
}

  

制作任务计划

  

每隔4小时运行一下脚本

  

添加参数
程序脚本:powershell #运行工具
添加参数:C: \ \ Movecomputer脚本。ps1 #脚本路径
起始于:C: \脚本\ #指定程序目录

  

将客户端主机移动到指定的或者内

将客户端主机移动到指定的或者内