In some situations like if we wish to study a new environment or restructure a existing environment or check user teams channels membership across the tenant. we have to Export all the Teams Channels and all the members of it to a CSV file. There is no command let available to retrieve the Teams and Channel members in bulk. Pipe line won’t work in this case. Its very similar to Distribution Group and its members like in Exchange online.Which i wrote a script many years back.
Lets see how to do similar stuff in Microsoft Teams PowerShell native module. if you want to know how to install latest repositories and
PLEASE NOTE YOU HAVE TO USE PRE RELEASE version for the script to work which is covered in below article. Get-TeamChannelUser doesn’t work on Production PowerShell Respository.
Install-Module PowerShellGet -RequiredVersion 2.2.4.1
To use pre-release version – (Get-TeamChannelUser is available only on pre release version for now)
Connect to Microsoft Teams Powershell i have covered in this article.
Choose the Task 1 to Export the minimal data and display in shell.
PS C:\Scripts> .\TeamsChannelMemberReport.ps1
Teams Channel Member Report
—————————-
1.Display in Microsoft Teams Shell
2.Export to CSV File
Choose The Task: 1
User SMTP Address Role Channel DisplayName Team DisplayName
—————– —- ——————- —————-
xx@localhost Owner General Teams_Azure365pro
xx01@localhost Member General Teams_Azure365pro
Choose the Task 2 to Export the all the Teams Channels Membership data with Teams settings to a CSV File.
PS C:\Scripts> .\TeamsChannelMemberReport.ps1
Teams Channel Member Report
—————————-
1.Display in Microsoft Teams Shell
2.Export to CSV File
Choose The Task: 2
Enter the Path of CSV file (Eg. C:\Teams.csv): c:\Scripts\Teams.csv
CSV Will Export Below Columns
- DisplayName
- UserId
- User SMTP Address
- Role
- Channel DisplayName
- Channel Description
- Channel MembershipType
- Team GroupID
- Team DisplayName
- Team Description
- Team Visibility
- Team MailNickName
- Team Classification
- Team Archived
- Team AllowGiphy
- Team GiphyContentRating
- Team AllowStickersAndMemes
- Team AllowGuestCreateUpdateChannels
- Team AllowGuestDeleteChannels
- Team AllowCreateUpdateChannels
- Team AllowCreatePrivateChannels
- Team AllowDeleteChannels
- Team AllowAddRemoveApps
- Team AllowCreateUpdateRemoveTabs
- Team AllowCreateUpdateRemoveConnectors
- Team AllowUserEditMessages
- Team AllowUserDeleteMessages
- Team AllowOwnerDeleteMessages
- Team AllowTeamMentions
- Team AllowChannelMentions
- Team ShowInTeamsSearchAndSuggestions
CSV File will look like –
Git Public Repository Link –
Hi
I dont get the Get-TeamChannelUser cmlet available. How do I make it avaialble for the script to run?
http://20.74.169.163/microsoft-teams-powershell/
Check this article.
Register-PSRepository –Name ‘_TempTestRepo’ –SourceLocation ‘https://www.poshtestgallery.com’
You have to use the pre release repository for now. To get the get-teamchanneluser
It will make it to production repository soon .
If you directly copy the command, the “-” will not be copied. Try copying the command below instead:
Register-PSRepository -Name ‘_TempTestRepo’ -SourceLocation ‘https://www.poshtestgallery.com’
Looks like that module is no longer available in https://www.poshtestgallery.com so I am unable to run the script.
Updated the article now. looks like its moved
I also got the error with missing ‘Get-TeamChannelUser’ command. I followed the guide to install this but still got the error. It’s worth mentoning that you have to may close PS and reconnect to Teams. The new module should then recognize the Get-TeamChannelUser as a valid command.
why use Add-Member in the code?
Add-Member is adding a Column in the sheet using PSObject. As we are collecting from two output.
I keep running into this error (Running powershell as admin)
WARNING: Unable to download from URI ‘https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409’ to ”.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider
‘NuGet’. The package provider requires ‘PackageManagement’ and ‘Provider’ tags. Please check if the specified package
has the tags.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 char:21
+ … $null = PackageManagement\Install-PackageProvider -Name $script:N …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power…PackageProvider:InstallPackageProvider) [Install-Pac
kageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
vider
PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name
‘NuGet’. Try ‘Get-PackageProvider -ListAvailable’ to see if the provider exists on the system.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 char:21
+ … $null = PackageManagement\Import-PackageProvider -Name $script:Nu …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProv
ider
I am fairly new to powershell, and this article would be extremely helpful for a project I am working on, any help is greatly appreciated!
Hi,
I tried all cmdlet for pre-release, it is still not working. Get-TeamChannelUser is not working. Is there any workaround?
Dear Hasan,
Without the preview version installed properly you will not see . Get-TeamChannelUser
try restarting powershell as well.
HI,
Thanks for this article.
what do we need to change in case if we need channels and their members’ list for only one of the team (not all teams).
thanks
Updated the script to allow specific teams export
Hello
I am still running into issues with this, and would appreciate some feedback:
Specifically, when running the following:
Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.3-preview -AllowPrerelease
I get the following to return:
A potential parameter cannot be found that accepts argument ‘requireversion’. Cannot convert value “1.1.3-preview” to type “System.Version”. Error: “Input string was not in a correct format”.
I even typed this command manually (checked to made sure i had no typos) and I still get this error.
Update:
I was able to get the pre-release version to install finally. However, I followed the step to do the following so that Get-TeamChannelUser cmdet would work, but it still fails when I run the script. I closed powershell window after I installed it, and opened a new one. I then connected to Teams with Connect-MicrosoftTeams. I tested Get-Teams and it showed me a list of all the teams. Thought, great, it will work now. Ran the script again, and it still won’t recognize Get-TeamCahnnelUser and fails.
Anything I can do to correct this issue?
Figured this out…
I ran the cmdlet to try and see what module were installed. Even though I installed the pre release version and it went through with no errors, the production version of teams module was installed.
I uninstalled that module, then reran the check module cmdlet. It was showing the prerelease version, but to be safe I uninstalled that. Re ran the steps to install the pre release version and checked to make sure it was the only one listed.
It was, so I ran the script again, and this time it actually generated the CSV file with NO failures!!! Wish I would have figured this out sooner… took me switching to a different computer and a few weeks of attempts to try and figure out why it wasn’t working(Again, as stated above, I am a powershell newbie).
Thanks for putting this together, and can confirm as of 9/2/2020 this script works.
Great that you went through all the hurdles. Everyone went through the same including myself. Welcome to the Club.
I had to run Install-Module PowerShellGet -Force -AllowClobber to get Install-Module MicrosoftTeams -AllowPrerelease -RequiredVersion “1.1.9-preview” installed.
Info here: https://docs.microsoft.com/en-us/microsoftteams/teams-powershell-install#install-teams-powershell-public-preview
Thank you for the detailed article.
you are most welcome
Hi,
I’m running the script but its only exporting details for teams I have in my actual teams application.
I have global admin and teams admin for my tenant, how can I get this to export all teams?
Thanks,
Greg
you need to install PowerShell modules to run them.
Office 365 tenant to tenant migration. I’ve successfully exported all my teams, channels, and members from the source. Now I need to import that list into another Office 365 organization just changing the domain. Do you have a script to do this?
Thank you very much!
Works perfect – just use the actual preview Version
“Install-Module MicrosoftTeams -AllowPrerelease -RequiredVersion “1.1.9-preview”
Getting this error. Went thru comments and still not sure how to handle this
Get-TeamChannelUser : You must call the Connect-MicrosoftTeams cmdlet before calling any other cmdlets.
Please help
also getting this
Get-Team : You must call the Connect-MicrosoftTeams cmdlet before calling any other cmdlets.
I have connected to microsoft teams as you explained earlier…
I have used your script successfully at the beginning of the year but its not working now. Can you help?