Tinribs Posted March 30, 2020 Posted March 30, 2020 Hi All Firstly please feel free to move this to a more appropriate forum if necessary. I have an O365 group (Unified Group) that has 122 too many members. It would seem that all of year 7 students are also in the year 8 mailing list. The Year 7 students are also in their own year 7 mailing list. I need to find a way to remove all the year 7 students from the year 8 list. I've managed to get a text list and CSV file of the year 7 and year 8 mailing lists. Is there a way to use the list of year 7 students as a feeder file and delete them from the year 8 list? For some reason the year 7 list is a standard mail-enabled security group but the year 8 list is an O365 unified group - not sure if that makes any difference. Pretty sure the commands for working on unified groups are different to those for standard groups. Any way is acceptable as long as it works and it teaches me a bit more about powershell - bit of a newbie when it comes to scripting so please be gentle! Thanks in advance...
HPlum78 Posted March 30, 2020 Posted March 30, 2020 First question I have is are you able to connect to your tenant? Second have you got a test group?
Tinribs Posted March 31, 2020 Author Posted March 31, 2020 I can connect to my tenant. I've done small things on powershell before - exported and imported into empty groups from CSV etc. I've just not done anything that involves reading from a text file or working on a unified group before. I'm guessing that this will involve some kind of loop or scripting rather than just one line at a time. I can make a copy of the group involved and use that as a test if necessary.
HPlum78 Posted March 31, 2020 Posted March 31, 2020 Yeah just checking where I need to start, let me throw something together....
Tinribs Posted March 31, 2020 Author Posted March 31, 2020 Thanks HPlum78 I've been playing around and managed to get this to work: Import-CSV "C:\members.csv" | ForEach-Object { Remove-UnifiedGroupLinks –Identity "TestO365Group" –Links $_.member –LinkType Members -Confirm:$false Write-Host "The user" $_.member "removed" } Obviously I used a CSV instead of a text flle but this seems to have worked. Apologies for not sending this earlier
HPlum78 Posted March 31, 2020 Posted March 31, 2020 One thing I will say if you do $userlist = import-csv ,instead of using $userlist | foreach-object use $userlist.foreach(). This is because they have done a load of work under the hood to improve the speed (.Net team have to be more accurate..)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now