With the release of PowerShell for Microsoft Teams a massive step has been taken towards an easier to manage application. I like Microsoft Teams and PowerShell, so what more could I wish for with PowerShell for Microsoft Teams.
In this post I’m going through the commands and this pains that I have found on my way. It’s only a new product so I would expect to find some issues.
Microsoft Teams all starts by installing the module. It’s made very easy as all you have to do is run the following in an administrator version of PowerShell
Once the module as been installed, we can get started with our discoveries.
To get started it always helps to run Get-TeamHelp first as this will give you an overview of the available commands.
This will show all of the 23 commands available.
Note that this PowerShell for Microsoft Teams is still in Beta as shown when you use Get-Help
Connecting to MicrosoftTeams
All of the Microsoft teams commands start by making a connection to your tenant.
There are multiple ways that you can use Connect-MicrosoftTeams.
A simple call the Connect-MicrosoftTeams will already work:
You will get a login dialog and a connection will be set up.
When you automate things you might want to use the -Credential parameter. So that you can reuse credentials once entered.
Disconnecting to MicrosoftTeams
There is a command available to disconnect, however I haven’t evr found a real need to do this as connecting to a different tenant can simply be done without disconnecting. I guess the disconnect will clean the connection up a bit better.
Get your teams
This command gets all the teams that a user belongs to. See my earlier posts https://veenstra.me.uk/2017/11/04/microsoft-teams-get-all-your-teams-using-powershell-part-2-resolved/
Note that you can only get your own teams. So far I found that even administrators can’t get an overview of a specific user that isn’t the administrator themselves. The Parameter -User therefore seems to be a bit useless.
Users management within a team
The command Get-TeamUser can give you all the users within a team. Using the -GroupId parameter you can select the team (or actually group) that you are interested in. The GroupId you can get my running a Get-Team first.
Additionally if you want to filter the users returned by their role then you could use the -Role parameter
Get-TeamUser -GroupId b7d0dfa6-9935-4587-871b-e942d99eae83 -Role guest
This will give you all the guest users within a specified group. in a similar way you cold get all the owners or members of a team.
If you want to add any users to a team then Add-TeamUser will give you what you need. Imagine that you cold now add a user to 100 teams in a matter of seconds.
And of course there is also a Cmdlet available to reove a user form you teams, Remove-TeamUser will do a jobs very nicely
Getting all channels within a team
I didn’t manage to get this to work.
The following error doesn’t seem to want to go away in any kind:
Get-TeamChannel : Error occurred while executing
Message: Resource not found for the segment ‘channels’.
At line:1 char:2
+ Get-TeamChannel -GroupId b7d0dfa6-9935-4587-871b-e942d99eae83
+ CategoryInfo : NotSpecified: (:) [Get-TeamChannel], ApiException
+ FullyQualifiedErrorId : Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException,Microsoft.TeamsCmdlets.PowerShell.Custom.GetTeamChannel
Team Member Settings
There are 2 CmdLets for team member settings:
Get-TeamMemberSettings and Set-TeamMemberSettings
The Get Cmdlet will return the current values of the settings
AllowCreateUpdateChannels : True
AllowDeleteChannels : True
AllowAddRemoveApps : True
AllowCreateUpdateRemoveTabs : True
AllowCreateUpdateRemoveConnectors : True
The Set CmdLet has Parameters for each of the settings so that you can change the settings
Team Messaging Settings
For Team Messaging settings we have again a Set and Get Cmdlet available.
The Set Cmdlet will make it possible to set the following 5 parameters:
Get-TeamGuestSettings and Set-TeamGuestSettings handle two of the settings available within Microsoft teams.
So this again matches the settings already available within the app.
Get-TeamFunSettings and Set-TeamFunSettings handle four of the settings available within Microsoft teams.
So this again matches the settings already available within the app and now available from the PowerShell Command line.
Team and Channel Creating
So now we have 4 Cmdlets left:
We’ll start by creating a new team.
New-Team -DisplayName "PowerShell Team" -Description "This was created by PowerShell" -AccessType Private -AddCreatorAsMember $true
There are two more options available Alias and Classification, however I’ve not found that these options do very much for now.
So some of the basic operations and settings are now available. This is by no means a complete set of PowerShell Cmdlets, so expect that there will be more Cmdlets to become available over time …