1. 程式人生 > >PowerShell實戰5: 批量增加AD組成員

PowerShell實戰5: 批量增加AD組成員

function 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()
            }
    }