简体   繁体   中英

move all member of OU to new-distributiongroup

I'm trying to set up some new distributiongroups and want to fill them with all members of an specific OU.

$allMemberofTestOU = get-qadgroup $ouNameT | get-qadmemberof

but my exchange management shell dont know this cmdlet. i dont know why.

I dont get the point how i can do this, i guess - simple, thing.

Long Version:

I have many OU which named like OU-ProgramName-** and want to move all of these members to an new distributiongroup name VL-ProgramName-**.

At the beginning, i get the content from a textfile with all Programnames and want to loop via ForEach (works).

Question:

I need help at getting all members of an OU and copy them to a new distributiongroup.

Best regards from germany

Paul

Edit:

I built another way to do the job. Im new to powershell, so i dont know if im doing it the right way.

 $OU = "CN=*-$ouName,OU=Prodfarm-Anwendungen,OU=LRA-CTRX,DC=kreis-gr,DC=de”                        
 $AD = New-Object System.DirectoryServices.DirectorySearcher([ADSI]"LDAP://$OU")                                         

 # Testfarm

    $newGroupT = "VLP_"+ $ouName + " Test C65"
        $Users = $AD.FindAll() | %{$_.Properties.samaccountname} | Sort-Object 
            $Users | New-Distributiongroup -Name $newGroupT -Members $_

All Get-QAD* CMDLets are part from the Quest ActiveRoles Management Shell plugin. There was a free version out there before Quest was bought by Dell. The free version is the reason why some blog posts refer to use them. However after the merge the free version was pulled from the Quest/Dell website and you can buy this plugin now directly from Dell/Quest here .

So your issue could be solved with two possible solutions:

1.) If you have installed the plugin, then you didn´t add the Quest ActiveRoles AD management snap-in at first via:

Add-PSSnapin Quest.ActiveRoles.ADManagement

2.) The Quest ActiveRoles AD management snap-in isn´t installed. If you wish to use the last known "free" version you can find that in the internet for example here . Keep noted that nobody knows if this is the original version! Keep also noted that the free version is a very old version as the current one is version 1.7. So you might also buy the new and latest one from Quest/Dell.

Update:

Here is a script I´m using which can add all users from a given OU to a given AD group . I run it via the Windows Scheduler and an task account. Once it run, it is adding all users from the given OU to an given AD group, means its auto updating the groups. You might adjust that one so that it fits your needs. Its a little bit advanced coding as it send out an error email if something failed, writes a log and used a function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM