Restoring private channel owners in EDU teams

%3CLINGO-SUB%20id%3D%22lingo-sub-1717902%22%20slang%3D%22en-US%22%3ERestoring%20private%20channel%20owners%20in%20EDU%20teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1717902%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20a%20question...%20just%20something%20I%20would%20like%20to%20share...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Atlas%20College%20is%20a%20school%20in%20The%20Netherlands.%205%20Schools%20under%20one%20board...%20500%2B%20staf%20and%204500%2B%20students.%20We%20started%20using%20O365%20some%20odd%203%20years%20ago...%20main%20app%20for%20co%20workers%20and%20students%20is%20Teams.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20immediately%20got%20interested%20in%20SDS%20to%20auto%20create%20edu%20teams.%20At%20that%20time%20there%20was%20no%20coupling%20available%20for%20our%20SIS%20system%20(Magister)...%20so%20using%20the%20SIS%20database%20back%20end...%20some%20Perl%20glue...%20some%20Flow%20automation%20I%20came%20up%20with%20a%20sync%20system%20which%20works%20fairly%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20of%20the%20flaws%20is%20that%20it's%20not%20really%20capable%20of%20dealing%20with%20things%20like%20network%20outages%20and%20such%20which%20result%20in%20an%20empty%20set%20of%20sections%2C%20students%20and%20teacher.%20In%20such%20a%20case%20all%20owners%20and%20members%20are%20removed%20from%20the%20teams.%20This%20was%20startling%20at%20first%20but%20is%20also%20self%20repairing%20by%20doing%20an%20new%20(manual)%20sync.%20(Yes%20I%20know...%20have%20to%20build%20in%20something%20for%20that%20event).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUp%20to%20this%20year%20that%20is....%20this%20school%20year%20had%202%20special%20things%3A%3C%2FP%3E%3CP%3E-%20teacher%20started%20using%20private%20channels%3C%2FP%3E%3CP%3E-%20for%20some%20reason%20we've%20had%202%20network%20outages%2C%20which%20are%20rare.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20there%20is%20a%20problem%20with%20private%20channels%3A%20their%20owners%20and%20members%20are%20not%20restored%20after%20a%20new%20good%20sync.%20My%20guess%20would%20be%20that%20there%20is%20no%20information%20which%20owners%20and%20members%20should%20be%20added.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20wrote%20a%20little%20PS%20(enclosed%20below)%20script%20which%20adds%20the%20team%20owners%20as%20owner%20of%20the%20private%20channel.%20Adding%20members%20is%20left%20to%20the%20owners%20(usually%20teachers).%20Not%20perfect...%20but%20something%20at%20least.%20MS%20Support%20did%20not%20have%20help%20on%20this%20subject%2C%20and%20I%20am%20still%20waiting%20on%20SDS%20support.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20script%20uses%20functions%20from%20the%20preview%20Teams%20module.%20It%20takes%20a%20CSV%20file%20with%20one%20column%20as%20input%3A%20the%20SIS%20ids%20of%20the%20teams%20involved.%20I%20can%20make%20this%20list%20from%20within%20my%20sync%20system.%20But%20you%20can%20adapt%20it%20for%20your%20environment%20off%20course.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps%20people%20having%20simular%20problems%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPeter%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Escript%20added%20below%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23%20HiddenChannelsOwners%0A%23%20p.kaagman%40atlascollege.nl%0A%0A%23%20Due%20to%20a%20sync%20error%20our%20edu%20teams%20were%20left%20without%20owners%20and%20student.%0A%23%20After%20a%20restore%20of%20the%20sync%20all%20owners%20and%20student%20are%20once%20again%20added%0A%23%20to%20the%20correct%20teams%20with%20all%20files%2C%20chats%20and%20such%20intact.%0A%23%0A%23%20But%20not%20the%20private%20channels%2C%20these%20are%20left%20without%20owners%20or%20members.%0A%23%0A%23%20This%20script%20partly%20restores%20ownership%20of%20these%20channels.%0A%23%20Ownership%20to%20the%20private%20channels%20is%20given%20to%20the%20team%20owners.%20I%20was%20not%0A%23%20able%20to%20find%20any%20information%20about%20membership.%20It's%20left%20to%20the%20owners%20to%0A%23%20add%20the%20members%20to%20the%20private%20channels%0A%0A%23%20Edu%20teams%20are%20identified%20by%20sis_id.%20A%20csv%20file%20containing%20those%20is%20exported%20from%0A%23%20our%20sync%20system.%20That%20way%20we%20only%20process%20the%20edu%20teams%20of%20interest.%0A%24sis_ids%20%3D%20Import-Csv%20-Delimiter%20%22%3B%22%20-Path%20C%3A%5CUsers%5Cpkn%5Cpowershell%5Csections_2209.txt%0A%0Aforeach%20(%24line%20in%20%24sis_ids)%7B%0A%20%20%23%20The%20MailNickName%20is%20used%20to%20identify%20the%20teams.%0A%20%20%23%20This%20name%20is%20composed%20as%20follows%20%22Section_%5Bsis_id%5D%0A%20%20%24mailnick%20%3D%20%22Section_%22%2B%24line.sis_id%0A%20%20%23%20Get%20an%20object%20with%20the%20information%20of%20that%20team%0A%20%20%24team%20%3D%20Get-Team%20-MailNickName%20%24mailnick%0A%20%20%23%20Get%20a%20list%20of%20owners%20for%20that%20team%0A%20%20%23%20These%20will%20be%20used%20to%20restore%20ownership%0A%20%20%24TeamOwners%20%3D%20Get-TeamUser%20-GroupId%20%24team.GroupId%20-Role%20Owner%0A%20%20Get%20a%20list%20of%20channels%20for%20that%20team%0A%20%20%24channels%20%3D%20Get-TeamChannel%20-GroupId%20%24team.GroupId%0A%20%20%23%20Itterate%20through%20that%20list%20of%20channels%0A%20%20foreach%20(%24channel%20in%20%24channels)%7B%0A%20%20%20%20%23%20We%20are%20only%20interested%20in%20private%20channels%0A%20%20%20%20if%20(%24channel.MembershipType%20-eq%20%22Private%22)%7B%0A%20%20%20%20%20%20%23%20Get%20a%20list%20of%20owners%20for%20that%20channel%0A%20%20%20%20%20%20%23%20A%20private%20channel%20is%20identified%20by%3A%0A%20%20%20%20%20%20%23%20-%20The%20groupid%20of%20the%20team%0A%20%20%20%20%20%20%23%20-%20The%20DisplayName%20of%20the%20channel%0A%20%20%20%20%20%20%24ChannelOwners%20%3D%20Get-TeamChannelUser%20-GroupId%20%24team.GroupId%20-DisplayName%20%24channel.DisplayName%20-Role%20Owner%20%0A%20%20%20%20%20%20%23%20Only%20interested%20in%20channels%20without%20an%20owner%0A%20%20%20%20%20%20if%20(%20-Not%20(%24ChannelOwners)%20)%7B%0A%20%20%20%20%20%20%20%20%23%20Report%20for%20debug%20if%20such%20a%20channel%20is%20found%0A%20%20%20%20%20%20%20%20%24tmp%20%3D%20%22Team%3A%20%22%2B%24team.DisplayName%2B%22%20Channel%3A%20%22%20%2B%24channel.DisplayName%20%2B%20%22%20has%20no%20owners%22%0A%20%20%20%20%20%20%20%20Write-Output%20%24tmp%0A%20%20%20%20%20%20%20%20%23%20Add%20the%20team%20owners%20as%20new%20owner%20of%20the%20pricate%20channel%0A%20%20%20%20%20%20%20%20foreach%20(%24TeamOwner%20in%20%24TeamOwners)%7B%0A%20%20%20%20%20%20%20%20%20%20%23%20TeamOwners%20allways%20has%20an%20owner%20without%20a%20name...%20skip%20that%20one%0A%20%20%20%20%20%20%20%20%20%20if%20(%24TeamOwner.User)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Report%20for%20debug%20reasons%0A%20%20%20%20%20%20%20%20%20%20%20%20%24TeamOwner.User%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20A%20private%20channel%20is%20identified%20by%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20-%20The%20groupid%20of%20the%20team%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20-%20The%20DisplayName%20of%20the%20channel%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20First%20add%20the%20TeamOwner%20as%20member%0A%20%20%20%20%20%20%20%20%20%20%20%20Add-TeamChannelUser%20-GroupId%20%24team.GroupId%20-DisplayName%20%24channel.DisplayName%20-User%20%24TeamOwner.User%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20After%20being%20added%20the%20user%20can%20be%20promoted%20to%20owner%0A%20%20%20%20%20%20%20%20%20%20%20%20Add-TeamChannelUser%20-GroupId%20%24team.GroupId%20-DisplayName%20%24channel.DisplayName%20-User%20%24TeamOwner.User%20-Role%20Owner%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1717902%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Visitor

Hi there,

 

Not a question... just something I would like to share...

 

The Atlas College is a school in The Netherlands. 5 Schools under one board... 500+ staf and 4500+ students. We started using O365 some odd 3 years ago... main app for co workers and students is Teams.

 

I immediately got interested in SDS to auto create edu teams. At that time there was no coupling available for our SIS system (Magister)... so using the SIS database back end... some Perl glue... some Flow automation I came up with a sync system which works fairly well.

 

One of the flaws is that it's not really capable of dealing with things like network outages and such which result in an empty set of sections, students and teacher. In such a case all owners and members are removed from the teams. This was startling at first but is also self repairing by doing an new (manual) sync. (Yes I know... have to build in something for that event).

 

Up to this year that is.... this school year had 2 special things:

- teacher started using private channels

- for some reason we've had 2 network outages, which are rare.

 

And there is a problem with private channels: their owners and members are not restored after a new good sync. My guess would be that there is no information which owners and members should be added.

 

So I wrote a little PS (enclosed below) script which adds the team owners as owner of the private channel. Adding members is left to the owners (usually teachers). Not perfect... but something at least. MS Support did not have help on this subject, and I am still waiting on SDS support.

 

The script uses functions from the preview Teams module. It takes a CSV file with one column as input: the SIS ids of the teams involved. I can make this list from within my sync system. But you can adapt it for your environment off course.

 

Hope this helps people having simular problems

 

Peter

 

script added below

 

# HiddenChannelsOwners
# p.kaagman@atlascollege.nl

# Due to a sync error our edu teams were left without owners and student.
# After a restore of the sync all owners and student are once again added
# to the correct teams with all files, chats and such intact.
#
# But not the private channels, these are left without owners or members.
#
# This script partly restores ownership of these channels.
# Ownership to the private channels is given to the team owners. I was not
# able to find any information about membership. It's left to the owners to
# add the members to the private channels

# Edu teams are identified by sis_id. A csv file containing those is exported from
# our sync system. That way we only process the edu teams of interest.
$sis_ids = Import-Csv -Delimiter ";" -Path C:\Users\pkn\powershell\sections_2209.txt

foreach ($line in $sis_ids){
  # The MailNickName is used to identify the teams.
  # This name is composed as follows "Section_[sis_id]
  $mailnick = "Section_"+$line.sis_id
  # Get an object with the information of that team
  $team = Get-Team -MailNickName $mailnick
  # Get a list of owners for that team
  # These will be used to restore ownership
  $TeamOwners = Get-TeamUser -GroupId $team.GroupId -Role Owner
  Get a list of channels for that team
  $channels = Get-TeamChannel -GroupId $team.GroupId
  # Itterate through that list of channels
  foreach ($channel in $channels){
    # We are only interested in private channels
    if ($channel.MembershipType -eq "Private"){
      # Get a list of owners for that channel
      # A private channel is identified by:
      # - The groupid of the team
      # - The DisplayName of the channel
      $ChannelOwners = Get-TeamChannelUser -GroupId $team.GroupId -DisplayName $channel.DisplayName -Role Owner 
      # Only interested in channels without an owner
      if ( -Not ($ChannelOwners) ){
        # Report for debug if such a channel is found
        $tmp = "Team: "+$team.DisplayName+" Channel: " +$channel.DisplayName + " has no owners"
        Write-Output $tmp
        # Add the team owners as new owner of the pricate channel
        foreach ($TeamOwner in $TeamOwners){
          # TeamOwners allways has an owner without a name... skip that one
          if ($TeamOwner.User) {
            # Report for debug reasons
            $TeamOwner.User
            # A private channel is identified by:
            # - The groupid of the team
            # - The DisplayName of the channel
            # First add the TeamOwner as member
            Add-TeamChannelUser -GroupId $team.GroupId -DisplayName $channel.DisplayName -User $TeamOwner.User
            # After being added the user can be promoted to owner
            Add-TeamChannelUser -GroupId $team.GroupId -DisplayName $channel.DisplayName -User $TeamOwner.User -Role Owner
          }
        }
      }
    }
  }
}

 

0 Replies