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

发布时间:2020-07-05 21:47:02 作者:Sir_Yuanzhe
来源:网络 阅读:543

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

###添加 ActiveDirectory power shell模块###
Import-Module ActiveDirectory
###将Windows7 企业版赋予变量###
####$windows7enterpise=Get-ADComputer -SearchBase "CN=Computers,DC=ljstaff,DC=com" -Filter {OperatingSystem -eq "Windows 7 企业版"} -Properties OperatingSystem,OperatingSystemVersion | select OperatingSystem,OperatingSystemVersion
$windows7enterpise ="Windows 7 企业版"

###将Windows7 旗舰版赋予变量###
$windows7Uitimate="Windows 7 旗舰版"

###将Windows10 企业版版赋予变量###
$windows10Enterpise="Windows 10 企业版"

###将Windows 10 专业版版赋予变量###
$windows10ProfessionalEdition="Windows 10 专业版"

###查看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 OU下的Windows 7 企业版计算机移动到 DAS OU内###
if ($lscomputer.OperatingSystem -eq "$windows7enterpise"){
Move-ADObject -Identity $lscomputer -TargetPath $dasou
###暂停###
#Pause
}
###将computers OU下的Windows 7 旗舰版计算机移动到 DAS OU内###
if ($lscomputer.OperatingSystem -eq "$windows7Uitimate"){
Move-ADObject -Identity $lscomputer -TargetPath $dasou
###暂停###
#Pause
}
###将computers OU下的Windows 10 企业版计算机移动到 DAS OU内###
if ($lscomputer.OperatingSystem -eq "$windows10Enterpise"){
Move-ADObject -Identity $lscomputer -TargetPath $dasou
###暂停###
#Pause
}
###将computers OU下的Windows 10 专业版计算机移动到 DAS OU内###
if ($lscomputer.OperatingSystem -eq "$windows10ProfessionalEdition"){
Move-ADObject -Identity $lscomputer -TargetPath $dasou
###暂停###
#Pause
}
}

制作任务计划

每隔4小时运行一下脚本

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

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

推荐阅读:
  1. 利用Netdom工具将客户端加到AD指定OU
  2. CS7: 指定客户端加入域时自动加入预定好的OU_方法1

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

客户端 主机移动 ou

上一篇:使用Commons Email发送邮件

下一篇:10天学通Android开发(1)-环境搭建和Hello测试

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》