功能:批量把AAA分公司的员工加入BBB分公司的员工安全组 – BBBemployees。
使用:如实战4,把AAA员工的名单导出至c:\name.txt
源码:
clsfunction Add_Group {
Process {
$root = [ADSI]""
$rootdn = $root.distinguishedName
$user = [ADSI]("LDAP://CN=$_,OU=AAA," + $rootdn)
$group = [ADSI]("LDAP://CN=BBBemployees,OU=BBB," + $rootdn)
$members = $group.member + $user.distinguishedName
$group.member = $members
$group.SetInfo()
}
}Get-Content c:\name.txt | Add_Group