Teams

Connecting to Skype for Business Online via PowerShell in a Hybrid Environment

How to connect to Skype for Business Online via Powershell

To connect to Skype for Business Online:

  • Download and install the module from Microsoft

  • Run the following commands in PowerShell:

    Import-Module SkypeOnlineConnector

    $sfboSession = New-CsOnlineSession -UserName “admin@contoso.com” -OverrideAdminDomain “yourtennant.onmicrosoft.com”

    Import-PSSession $sfboSession

    Applies To : Windows 10, Windows Server


    I’ve been caught out by this twice and it’s taken me a while to find the rather simple answer.

    Most instructions give you a pretty simple way to connect to Skype for Business Online (or they’ll just call it Skype for Business). You install the module via executable, downloaded from Microsoft, and then try to run the following PowerShell commands (or some similar variation):

    Import-Module SkypeOnlineConnector
    $sfboSession = New-CsOnlineSession -UserName "admin@contoso.com"
    Import-PSSession $sfboSession

    If you don’t have Skype for Business On-Premises, it should just work. If you DO have it and set up hybrid, you’ll probably get this error:

    Unable to discover PowerShell endpoint URI.
    At C:\Program Files\Common Files\Skype for Business
    Online\Modules\SkypeOnlineConnector\SkypeOnlineConnectorStartup.psm1:155 char:9
    +         throw $resources.DiscoveringEndpointFail
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (Unable to disco...l endpoint URI.:String) [], RuntimeException
        + FullyQualifiedErrorId : Unable to discover PowerShell endpoint URI.

    Or, you might get this error if you managed to get the interactive logon to pop up first and then entered your credentials there:

    Get-CsOnlinePowerShellAccessToken : One or more errors occurred.
    At C:\Program Files\Common Files\Skype for Business
    Online\Modules\SkypeOnlineConnector\SkypeOnlineConnectorStartup.psm1:214 char:28
    +             $accessToken = Get-CsOnlinePowerShellAccessToken @params
    +                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Get-CsOnlinePowerShellAccessToken], AggregateException
        + FullyQualifiedErrorId : System.AggregateException,Microsoft.Rtc.Management.OnlineConnector.GetPowerShellAccessTo
       ken

    There’s a huge amount of potential fixes offered, but for me it was one simple switch, which I found thanks to enterinit.com – use the -OverrideAdminDomain switch.

    Import-Module SkypeOnlineConnector
    $sfboSession = New-CsOnlineSession -UserName "admin@contoso.com" -OverrideAdminDomain “yourtennant.onmicrosoft.com”
    Import-PSSession $sfboSession

    Really easy fix, but the errors really don’t make it sound like this could be your problem. Now the next time I try to connect, I’ll re-read my own blog post to remind me of this switch :)

    Note: I had to connect to this to make a Microsoft Teams change!

    Default Cloud Voicemail Language

    When Cloud Voicemail a.k.a. Azure Voicemail (which replaced Unified Messaging) is activated for a mailbox, a default language is set. This value is known as the ‘promptlanguage’ and according to Microsoft Documentation will be set based on the default language for your organisation in the Microsoft 365 admin center.

    The problem is, that value is ‘English’ and doesn’t define which regional set of English you want – en-US, en-UK, en-AU etc. The full list of language codes is available here.

    With Engish set as the preferred language, Azure Voicemail decides that you must be wanting en-US as your promptlanguage – which you may not actually want. The default voicemail greeting is rather different when set to en-US vs en-UK vs en-AU.

    If you’d like to see what a user has, use the PowerShell command:

    Set-CsOnlineVoicemailUserSettings -identity XYZ@XYZ.COM

    and check the value ‘PromptLanguage’.

    On a per user basis, this value can be changed either by the user themselves at https://mysettings.lync.com/voicemail or by an admin with the PowerShell command:

    Set-CsOnlineVoicemailUserSettings -identity XYZ@XYZ.COM -PromptLanguage en-AU

    This still doesn’t solve the tenant wide problem, or set a default.

    For existing users, we just need to get a list of users and change the promptlanguage setting, which can be done with this set of PowerShell commands (includes connecting to SfBO which can be used for the above command also):

    $sfbsession = new-csonlinesession -username adminaccount@conotoso.com -OverrideAdminDomain contoso.onmicrosoft.com


    Import-PSSession $sfbsession


    $users = Get-CsOnlineuser


    foreach ($user in $users) {set-csonlinevoicemailusersettings -identity $user.userprincipalname -promptlanguage en-AU}

    Note the use of the -OverrideAdminDomain switch, which I learnt from this blog post in case you are having issues connecting to Skype for Business Online.

    This process also may take a long time depending how many users you have, as very roughly it takes about a second per user to change the value.

    This will fix your existing users, but what about new ones? You could have the setting modified set as part of the user creation process, but that’s an extra step and you’d need to wait for Azure Voicemail to be ready – in my experience it’s not a service that’ll be available quickly after enabling. At this stage I haven’t found a way to do it though, so you’ll need to consider adding this configuration as part of user setup.

    If you haven’t even thought about what language you’re using – have a look and try each one, as you might find one that you’re happier with than the US.

    Managing Unified Messaging Users in Exchange Online

    error
    The phone number you entered has already been registered by someone else.

    This is the standard error you’ll see in the Exchange admin center when trying to enable Unified Messaging on an extension that already has it enabled.

    When a user departs you’d expect that when you change the user mailbox to a shared mailbox and drop the licensing, Unified Messaging should go. However, in Exchange Online the mailbox will still be Unified Messaging (UM) enabled, and hang onto the extension it had.

    You probably won’t even notice this until you go to enable UM on another mailbox using that same extension, which leads to the error at the top of this article.

    The first challenge is to find the Shared Mailbox that is holding onto the extension. After connecting to Exchange Online in PowerShell, you can run this command:

    get-ummailbox | select name, phonenumber | out-gridview

    This will show a nice gridview of all your mailboxes and what UM extension they have. You can search/filter this view to find the cuplrit.

    If you want to see which of your mailboxes are Shared and have UM enabled, run this command:

    Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited -filter {umenabled -eq "true"}

    Knowing this mailbox, you’d expect it should be easy to turn off UM. This wouldn’t be too much of a problem if you could just disable UM like you can on a normal mailbox, but in Exchange admin center this isn’t an option at all when it’s a shared mailbox.

    Trying to disable UM via PowerShell with the ‘Disable-UMMailbox’ command also won’t work, as you’ll get a license error:

    License validation error: the action 'Disable-UMMailbox', 'Identity', can't be performed on the user 'Test User'
     with license 'BPOS_S_Standard'.
         + CategoryInfo          : NotSpecified: (:) [Disable-UMMailbox], RuleValidationException
         + FullyQualifiedErrorId : [Server=SYXPR01MB1901,RequestId=dfc62192-8270-4a65-b582-c7f327d6e7e2,TimeStamp=15/10/201
        9 6:24:33 AM] [FailureCategory=Cmdlet-RuleValidationException] DDB44050,Microsoft.Exchange.Management.Tasks.UM.Dis
       ableUMMailbox
         + PSComputerName        : outlook.office365.com

    To fix this, you could use the Exchange admin center GUI along with the Microsoft 365 Portal, but it’s easier to run all the steps required via PowerShell:

    First apply a license to the shared mailbox account that includes Exchange Online. You can see what licenses are available to you with this PowerShell command used by the MsolService cmdlet:

     Get-MsolAccountSku

    Then, apply a license with this command against the shared mailbox and the AccountSkuID from the previous command:

    Set-MsolUserLicense -UserPrincipalName "UPN OF SHARED MAILBOX" -AddLicenses "tenant:licensename"

    Once applied, you’ll then need to change the mailbox to a Regular mailbox rather than Shared:

    Set-Mailbox "UPN OF SHARED MAILBOX" -Type Regular

    After a while, Unified Messaging may drop off by itself if you allocated a license that doesn’t support it (such as Exchange Online Plan 1 or Exchange Online Kiosk, or you can force it off with this command:

    Disable-UMMailbox -Identity  "UPN OF SHARED MAILBOX"

    Finally you can now enable UM on that other mailbox that was getting the error on the extension being in use. Easily done via the Exchange admin center GUI.

    Two last steps are then to reverse what you did – take the license away from the shared mailbox, and make it a shared mailbox again:

    Set-MsolUserLicense -UserPrincipalName "UPN OF SHARED MAILBOX" -RemoveLicenses "tenant:licensename"
    
    Set-Mailbox "UPN OF SHARED MAILBOX" -Type Shared

    Office 365 Extra Features Overview

    In September 2017, I presented at the user group I co-own with Brett Moffett on the topic of Office 365 Extra Feature Overview. I wanted to show some of the key parts of Office 365 beyond Exchange, SharePoint and Skype for Business. Here’s a recording of that presentation:

     

    Forms is still my favorite ‘quick win’ feature, which I previously covered along with a sample form and results.

    If you’re ever in Adelaide and want to come along to our monthly catchups, here’s our Meetup page: https://www.meetup.com/preview/Adelaide-Microsoft-ITPro-Community