I am primarily writing this article for myself as a cheat-sheet on how to get connected with PowerShell in order to manage Microsoft Teams.
Open PowerShell with "Run as Administrator" and type (or copy) the following commands.
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Now a prompt / window will pop-up and you can enter the password for the admin user specified above. Change this username to the Admin account you are using in Office 365 of course. Next run the commands
Connect-MicrosoftTeams -AccountId $adminUPN
At this stage you are connected to the Teams PowerShell part of Office 365, you can now use commands such as
Get-Command -Module MicrosoftTeams
However, if you now try to use a command containing *cs* such as
You will get the message "The term 'get-csTeamsmeetingpolicy' is not recognized as the name of a cmdlet, function, script file, or operable program." because all *cs* commands are part of the legacy Skype for Business Online PowerShell interface. To connect to SfB Online PowerShell use the following commands
$sfbSession = New-CsOnlineSession -Credential $userCredential
If you again get the message "The term 'New-CsOnlineSession' is not recognized as the name of a cmdlet, function, script file, or operable program." you need to download and install the Skype for Business Online, Windows PowerShell Module and also close the current PowerShell window, open a new one and continue from there. Now
will work. Next, connect to SharePoint Online using the command
Connect-SPOService -Url https://M365x086920-admin.sharepoint.com -Credential $userCredential
Again, if you get the message "The term 'Connect-SPOService' is not recognized as the name of a cmdlet, function, script file, or operable program." you need to download and install the SharePoint Online Management Shell and also close the current PowerShell window, open a new one and continue from there. Now commands such as
Get-Command -Module Microsoft.Online.SharePoint.PowerShell
will work as well. At this point you can even use Ståle Hansens great oneliner if you are moving users from Skype for business to Microsoft Teams.
Get-CsOnlineUser admin@M365x086920.onmicrosoft.com | Format-List UserPrincipalName, DisplayName, SipAddress, Enabled, TeamsUpgradeEffectiveMode, EnterpriseVoiceEnabled, HostedVoiceMail, City, UsageLocation, DialPlan, TenantDialPlan, OnlineVoiceRoutingPolicy, LineURI, OnPremLineURI, OnlineDialinConferencingPolicy, TeamsVideoInteropServicePolicy, TeamsCallingPolicy, HostingProvider, InterpretedUserType, VoicePolicy
For more information, please take a look at:
Thank you for this blog post. It was very helpful.ReplyDelete
Thank you very helpfulReplyDelete
Very helpful, just what i was looking for as the ps administration of Teams is still split brained with Sfb...Awesome! :DReplyDelete
Extremely helpful. I will note that I had errors originally and had to follow the steps atReplyDelete
to "get the red out" of the script. :-)
Thanks, you saved me after a frustrating afternoon.ReplyDelete
i have to use "Import-Module SkypeOnlineConnector" to connect, but the rest is very helpfullReplyDelete
Thank you very much! This helped me a lot! Very thorough description and solution, which I looked for.ReplyDelete
great article - thanksReplyDelete