Changing Lync/SfB Server PowerShell windows size

A quick way to change the Lync/SfB Server PowerShell window size is to run the following cmdlets:

[code language=”powershell” light=”true”]

$pshost = get-host
$pswindow = $pshost.ui.rawui
$newsize = $pswindow.buffersize
$newsize.height = 3000
$newsize.width = 120
$pswindow.buffersize = $newsize
$newsize = $pswindow.windowsize
$newsize.height = 50
$newsize.width = 120
$pswindow.windowsize = $newsize

[/code]

However, this change is temporary, when we open a new Lync/SfB Server PowerShell it will return to the default values.

To modify the default values we need to change Layout settings in the Lync/SfB Server PowerShell shortcut properties:

Lync Server 2013

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Lync Server 2013

Skype for Business Server 2015

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype for Business Server 2015

Please note that these are the same values as the Windows PowerShell.

After these changes the Lync Server 2013 will work fine:

However, for Skype for Business Server we have an issue when we try to use the SfB PowerShell shortcut:

The string is missing the terminator: ‘.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

The issue is cause by the 260 characters limitation in the Shortcut Target:

We can quickly fix this by using Windows PowerShell:

[code language=”powershell” light=”true”]

$ShortcutPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype for Business Server 2015\Skype for Business Server Management Shell.lnk"
$Shell = New-Object -ComObject ("WScript.Shell")
$Shortcut = $Shell.CreateShortcut($ShortcutPath)
$Shortcut.Arguments = "-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\SkypeForBusiness\SkypeForBusiness.psd1’"""
$Shortcut.save()

[/code]

After this we are able to use Skype for Business PowerShell:

For the Skype for Business Server 2019 PowerShell we don’t need to change the default value:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype for Business Server 2019