Monday 20 August 2018

Skype for Business Server 2019 management shell missing terminator

Hello readers,

Hope you're well.

A really quick one this time.

If you've been working with Microsoft UC server products as long as I have you'll no doubt be familiar with this one.  I've seen this error with every product since Lync 2010.  I don't know if it was present in OCS or LCS before it.

The problem
You go to open the Skype for Business Server Management Shell and you get an error on opening.
The string is missing the terminator: '. 
       + CategoryInfo                 : ParserError: (:) [], ParentContainsErrorRecordException
       + FullyQualifiedErrorId   : TerminatorExpectedAtEndOfString


The error doesn't stop you using it.  It is annoying, however and deserves to be fixed.  This is in Skype for Business Server 2019.  You'd expect it to have been fixed by Microsoft by now.


The cause
The reason you get the error is because when the shortcut was created it used a "Target Path" which was truncated from the full path.

Typically, the path looks like this
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd $env:UserProfile; Write-Host 'Loading Modules for Skype for Business Server 2019...'; Import-Module 'C:\Program Files\Common Files\Skype for Business Server 2019\Modules\SkypeForBu

It should look like this
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd $env:UserProfile; Write-Host 'Loading Modules for Skype for Business Server 2019...'; Import-Module 'C:\Program Files\Common Files\Skype for Business Server 2019\Modules\SkypeForBusiness'"

Clearly, this is missing the end of the word Business, an apostrophe and an end quote.

The problem is, that's too many characters for the field which is limited to just 259 (odd number) characters.

In the Lync days it was cased by the missing quotation at the end rather than number of characters (since Lync is a lot shorter than Skype for Business).


The solution
Shorten the path while completing the module name and including the terminators, of course.

All you need is siness'"

My suggestion is to remove the word "server" and remove one of the "." at the end of the Write-Host statement.
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd $env:UserProfile; Write-Host 'Loading Modules for Skype for Business 2019..'; Import-Module 'C:\Program Files\Common Files\Skype for Business Server 2019\Modules\SkypeForBusiness'"

This saves you enough characters to let you finish the statement.

How to do it
You need to open up the properties on the shortcut.

Browse to 
%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

Right click on the shortcut and click properties

If, like me, you pinned the shortcut to the taskbar.  Right click on the icon, then right click on Skype for Business Server Management Shell and click properties.

This opens up the properties page

As you can see the Target field has the truncated statement ending in SkypeforBu.

Paste in your new, shortened target
e.g. C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd $env:UserProfile; Write-Host 'Loading Modules for Skype for Business 2019..'; Import-Module 'C:\Program Files\Common Files\Skype for Business Server 2019\Modules\SkypeForBusiness'"

and click apply and OK

Now click on the shortcut to open the management shell


That's all folks.  Hope this helps.

___________________________________________________

Thanks for reading.

If this or any other post has been useful to you please take a moment to share.  Comments are welcome.