Forum Discussion

Tien Ngo Thanh's avatar
Tien Ngo Thanh
Iron Contributor
Oct 27, 2019

add/remove dynamic member in microsoft teams

Hi

     How to write powershell to add/remove member in microsoft teams . I want add all user in OU to microsoft teams and also remove member if they not in this OU , please anyone guide help me

Best regards,

Thanks

  • Since Office 365/Azure AD does not have OUs, you will either have to export the list of OU users to a CSV file, or write a script that combines output from the AD and Office 365 modules. Here's a example for the former case:

     

    $users = Get-UnifiedGroupLinks TeamName -LinkType member

    Import-Csv .\blabla.csv | % { if ($_.UserPrincipalName -notin $users.WindowsLiveID) {Write-Host "Adding user $($_.UserPrincipalName)"; Add-UnifiedGroupLinks TeamName -LinkType member -Links $_.UserPrincipalName } else {Write-Host "Removing user $($_.UserPrincipalName)"; Remove-UnifiedGroupLinks TeamName -LinkType member -Links $_.UserPrincipalName} }

     

    That's assuming the blabla.csv file has a column UserPrincipalName to designate the users (members of the OU).

    • Tien Ngo Thanh's avatar
      Tien Ngo Thanh
      Iron Contributor

      hi

          I try add member but after done add member then microsoft teams update member but when access sharepoint site then see new member .Microsoft teams not update member i try logout and login Microsoft teams again but still not see

      Best Regards,

      • VasilMichev's avatar
        VasilMichev
        MVP

        You'll have to wait for the membership changes to be synchronized across all workloads.

Resources