Forum Discussion

AxelRumkorf's avatar
AxelRumkorf
Copper Contributor
Sep 02, 2020

Powersehll Beginner - Add multiple Users to group

Hello, I am a Powershell beginner. I'm responsible for user maintenance in Microsoft 365 at our school and have to prepare the approximately 1000 students and 100 teachers in such a way that teams are created as easily as possible. Due to the Corona situation we were put in this position from now on. Unfortunately our school - like so many others - does not have professional IT, so this work is done "on the side".
I have tried to create class groups for the new school year where no teachers have been assigned yet. The teachers should decide for themselves whether a team is created or not. With SchoolDataSync the creation of the groups worked, but the groups all have the parameter "HiddenGroupMemmbershipEnabled" and only the group owner can create a team.
I have not found a way to change this parameter.
In Powershell I tried to fill a manually created group with users using a simple script.

 

 

Import-csv C:\temp\groups.csv
Import-Csv C:\temp\groups.csv | ForEach-Object {Add-ADGroupMember -Identity $_.groupname -Members $_.username}

 

 

But unfortunately I get the following error, which overtaxes me as a beginner.

 

username                              groupname
--------                              ---------
xxx.bu@mariengym-jev.de           Gtest20  
xxx.cardo.santos@mariengym-jev.de Gtest20  
xxx.corn@mariengym-jev.de   Gtest20  
xxx.eil@mariengym-jev.de         Gtest20  
xxx.eile@mariengym-jev.de          Gtest20  
Add-ADGroupMember : Es wurde kein Standardserver gefunden, auf dem die Active Directory-Webdienste ausgeführt werden.
In C:\temp\groups_import_sus.ps1:2 Zeichen:49
+ ... ach-Object {Add-ADGroupMember -Identity $_.groupname -Members $_.user ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (Gtest20:ADGroup) [Add-ADGroupMember], ADServerDownException
    + FullyQualifiedErrorId : ActiveDirectoryServer:1355,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember

 

 

As a school, we actually need 4 scripts to be able to cope with everyday life and the school year:

1. A script to create many groups (at each school year change).
2. A script to assign the users to the groups.
3. A script to create new students.
4. A script to remove students/users who have left the school.

 

This should always be done with CSV files if possible.

Or are there other possibilities for schools? Sorry, here in Germany we are unfortunately still at the very beginning with Micrsoft teams.

 

I am grateful for any help - please also tell me if this is the wrong place to ask and I should better ask at another place.

Best regards
Axel Rumkorf

Resources