Get-Team Using CSV

Running into a situation where we need to update numerous blank user details(title/department). Only way we see to do this is to grab which team they are in. However, iterating over one column titled, “email” with nothing but upn’s just spits out our entire channel list.

Command run: Import-CSV <path>\getteam.csv | % { Get-Team -User $ } | Export-csv <path>\exportteam.csv

We need a way to grab a list of user’s team memberships if possible!

I have not worked much specifically with Teams in Powershell, but I would recommend leveraging the Azure module to identify Azure groups a user belongs to and correlate that to Teams since Team membership is basically Azure groups.

Where are you wanting to update things such as Title and Department? spreadsheet? database?

Azure AD is where attributes such as title and department will be found, not teams. Get-Team is for getting a list of teams in your environment and finding which teams a user is a member of. It won’t tell you much else. It will not provide information such as what an ID’s title is.

If you want to look at more user detail in terms of how Teams “views” a user ID, Get-csOnlineUser is the cmdlet you want. It actually does return title and department, but these attributes and values are NOT in teams per say, they are sourced from Azure AD.

Teams actually holds very little if any “data” itself. It is built on top of Azure AD, SharePoint, M365 groups, OneDrive, and Exchange. Those are the places data is actually held depending on what data you are looking for.

Depending on exactly what data you are trying to extract, you will likely need to build a script that uses a couple different cmdlets to gather the data into a custom object, then export it all to a csv when done.

With more detail, I might be able to help some more.

1 Like

Hi Matt,

Thank you for your input. This is very useful information. I may have been a little vague with my end game. We currently have about 250 users with empty title/department fields. My best idea to fill those fields was to grab the UPN’s from our O365 active user’s with the missing information and see what memberships they are a part in order to see what department they actually are in. From there we would run the Set-User command with the missing information filled in.

I hope that explains it a bit better!

Edit: I should mention our tenant is not on-prem and entirely in the cloud. Not sure if we have access to all of the Azure commands.

Generally speaking, the best source of information for some of the attributes that make up an ID within your organization, particularly for correct names, title, department, manager and such is HR. HR tends to be the best source of authoritative and trusted data for such things.

Flowing that data into your tenant can be done through automation. There are various ways this can be done. But by leveraging HR you can automate updates in title changes, manager changes, if an ID should be enabled or not etc.

Depending on naming convention and process for group creation and creation of teams within Teams, the names may or may not actually help you. left to their own devices and allowed to create groups on their own, users will not necessarily create groups with names that correspond to their title and department.

From a PowerShell perspective, there are multiple modules you can use to manage your tenant, and which to use depend on your role.

The Azure module is for working with the much of the underlying settings for your tenant. You are not likely to need or have access to this if you are not part of the team that actually admins the Azure tenant. I bring it up only because you mention “Azure commands”.

The AzureAD module is more what you need. This is module to use if you want to view AzureAD accounts, groups etc. You should be able to use the “get” cmdlets without special roles since you aren’t trying to change anything, just get basic public information. (note, set-user is an on prem cmdlet)

The Teams module is where the get-team, get-csonlineuser are. sounds like this is one you already have.

There is other are other modules, but the azureAD module is the one you will likely get the most out of given what you share.