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.
$adminUPN="admin@M365x086920.onmicrosoft.com"
$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
Install-Module MicrosoftTeams
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
Get-Team
However, if you now try to use a command containing *cs* such as
Get-CsTeamsMeetingPolicy
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
Import-PSSession $sfbSession
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
Get-CsTeamsMeetingPolicy
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
Get-SPOSite
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.
ReplyDeleteThank you very helpful
ReplyDeleteVery helpful, just what i was looking for as the ps administration of Teams is still split brained with Sfb...Awesome! :D
ReplyDeleteExtremely helpful. I will note that I had errors originally and had to follow the steps at
ReplyDeletehttps://jeffbrown.tech/errors-connecting-to-skype-for-business-online-powershell-module/
to "get the red out" of the script. :-)
Thanks, you saved me after a frustrating afternoon.
ReplyDeletei have to use "Import-Module SkypeOnlineConnector" to connect, but the rest is very helpfull
ReplyDeleteThank you very much! This helped me a lot! Very thorough description and solution, which I looked for.
ReplyDeletegreat article - thanks
ReplyDelete