Skype for Business Management Shell: The string is missing the terminator

Hi All

if you see the error "The string is missing the terminator: '. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException" when running Skype for Business 2015 Management Shell for Powershell, it is due to an error with the Target for the shortcut added when installing Skype for Business 2015. There is a limit in the number of characters (I believe 255) that can be used in a shortcuts target and unfortunately the Skype for Business module path  which includes loading up a Powershell module and write-host'ing a nice message exceeds the limit.

Out of the box the Target used by the shortcut is:

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd $env:UserProfile; Write-Host 'Loading Modules for Skype for Business Server 2015...'; Import-Module 'c:\Program Files\Common Files\Skype for Business Server 2015\Modules\SkypeForBu

This of course is no good as the SkypeforBusiness path has been truncated. Fortunately in Windows Server 2012 and Windows Server 2012 R2, the operating system finds and load Powershell modules for you out of the box. So actually performing the Import-Module of the Skype for Business Powershell cmdlets isn't necessary on these operating systems. But that said the error message displayed every time you start the management shell gets annoying quickly.

Solution:

So to fix the error, you can paste the following string into the Target which has been shortened by using a much shorter write-host message.

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "cd $env:UserProfile; Write-Host 'Loading SFB..'; Import-Module 'C:\Program Files\Common Files\Skype for Business Server 2015\Modules\SkypeForBusiness'"

Thanks to Matt W a fellow PFE in the US for picking this up as it had been bugging me and I hadn't taken the time to look at why it was breaking!

 

Happy Skype/Lync'ing.

Steve