Pages

Monday, October 7, 2019

PowerShell for Teams Management

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:

8 comments:

  1. Thank you for this blog post. It was very helpful.

    ReplyDelete
  2. Thank you very helpful

    ReplyDelete
  3. Very helpful, just what i was looking for as the ps administration of Teams is still split brained with Sfb...Awesome! :D

    ReplyDelete
  4. Extremely helpful. I will note that I had errors originally and had to follow the steps at
    https://jeffbrown.tech/errors-connecting-to-skype-for-business-online-powershell-module/
    to "get the red out" of the script. :-)

    ReplyDelete
  5. Thanks, you saved me after a frustrating afternoon.

    ReplyDelete
  6. i have to use "Import-Module SkypeOnlineConnector" to connect, but the rest is very helpfull

    ReplyDelete
  7. Thank you very much! This helped me a lot! Very thorough description and solution, which I looked for.

    ReplyDelete