Skype For Business

PowerShell – ‘While’ Loop Statement

There’s a lot of different ways to loop commands in PowerShell, and here’s one I just learnt (thanks Nathan Kewley for spending the time talking me through this!):

Scenario: You create a brand new user in Active Directory, but need to wait for things to sync before you make a change to the user. If you want to automate these steps, you want to check that the user exists before running more commands against it.

Answer: The ‘While‘ statement. This lets you loop a command ‘while’ something is a certain value. For example, you may want a script to loop for two minutes, or until a certain value is true or false.

With my script below, it will check if the value $running is nothing (null), which it is because we just made it up. Because it’s true, it’ll then continue on to do whatever is in the curly brackets. Here, I’m running a command the enable a user in Skype for Business, but also setting the result of that as the variable $running.

If the command works, $running now has a value of the created user, so as it loops again to see if $running is null, it won’t be, and the ‘while’ statement is done.

If the command fails however, and shows the dangerous red warning around the user not existing, nothing gets set to the $running variable. That means, when it loops again, $running will still be null so it’ll try again and again and again.

while($running -eq $null){
 $running = Enable-CsUser -Identity testuser -SipAddress

That’s rather dangerous of course, what if it’s forever $null? It’ll run forever, so we’d better put in some failsafes.

while($running -eq $null){
 if($CheckUser -le '10'){
  start-sleep -s 10
  $running = Enable-CsUser -Identity testuser -SipAddress

OK, this time we’re doing a couple more things. We’ve got two curly bracketed things to run now, the first is an ‘If’. If $CheckUser is less or equal to 10, then do the next curly bracket thing. The first time this runs that value again doesn’t exist because we just made it up, and nothing is less or equal to 10. The If statement is true, so it moves onto the next segment.

The $CheckUser++ command just adds ‘1’ to the value of $CheckUser – starting off at null or 0, so will turn into 1. As the statement loops, that number will increment all the way up to 11. Once it’s 11, the If statement is no longer true, so bombs out.

We’ve also added the start-sleep command, which is just a 10 second wait before doing anything. If we didn’t have that there, the 11 loops before it fails would be over incredibly quickly.

The last thing we can add is an event to occur once the ‘If’ statement is no longer true:

while($running -eq $null){
 if($CheckUser -le '10'){
  start-sleep -s 10
  $running = Enable-CsUser -Identity testuser -SipAddress
Throw "Unable to create SfB User"

All we’ve done here is added the ‘Else’ section, which only runs when the ‘If’ isn’t true. Once the $CheckUser variable hits 11, the ‘Else’ command runs and throws up an error, with the aptly named ‘Throw’ command.

Hopefully this is enough to explain the basics of the ‘While’ command.

Skype For Business 2016 – Flashing Active Call Window

After rolling out Skype for Business 2016 with Enterprise Voice as part of the Office 2016 suite, we discovered a weird UI issue. This is nothing but a display problem, but can still be a little distracting and annoying!

On a certain call type – incoming PSTN calls – the little active call window would flash. This took some testing to realise, as logically there shouldn’t be a corellation with how a call got to your Skype for Business client, and a display issue with a call window; but it was repeatable time and time again, on multiple PCs with different logins.

I then found a Technet thread on the issue, but this was for the older Skype for Business 2015 client, which is pretty much a reskinned Lync 2013 client. That patch wasn’t applicable to Skype for Business 2016.

I then decided to log a Microsoft Premier case, which was rather quick and after showing them the problem and waiting a few days, they came back to say the problem was planned to be fixed in the Skype for Business 2016  – December 2016 patch.

We’ll see what happens in December and I’ll update this post, but in case others discover this issue, it’s not you and you’ll need to wait a few months 🙂

Mail Merge Crashes When Opening Data Source

word crash

Sharing another problem and resolution I came across.

Recently, staff started complaining about Mail Merge crashing at the point of selecting a data source use. It was easily recreatable, and caused this event viewer error:

Faulting application name: WINWORD.EXE, version: 14.0.7113.5001, time stamp: 0x52866c04
Faulting module name: mso.dll, version: 14.0.7106.5003, time stamp: 0x5231bdf1
Exception code: 0xc0000005
Fault offset: 0x00c23ab0
Faulting process id: 0xe48
Faulting application start time: 0x01d204e6d69112b6
Faulting application path: C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE
Faulting module path: C:\Program Files (x86)\Common Files\Microsoft Shared\office14\mso.dll
Report Id: 3bf6bbe2-70da-11e6-bd32-b8763fabbff5

Pretty standard for a crash. In our environment, we had changed from Lync 2010 to Skype for Business 2016, and installed Skype for Business through the Office 2016 installer rather than standalone, to make future Office product updates easier (Skype for Business standalone won’t co-exist with an Office 2016 suite install).

For some reason, this upgrade process has broken the mail merge function for Microsoft Word. The quick fix was to do a repair of the Office 2010 suite after the Office 2016 install, and mail merge worked again.

It’s worth noting that a computer that had Office 2010 suite and Office 2016 (Skype for Business only) worked fine, it was only if Lync 2010 was installed first and then removed, then Office 2016 installed.

Blank Page For Skype For Business Web App


I had an issue recently where remote clients couldn’t connect to Skype for Business online meetings – when clicking the link, all they saw in the browser was a blank page. The tab of the browser showed ‘Skype for Business Web App’ but the page area had nothing.

This didn’t seem to affect all external clients (internal was fine), when I tested on Windows Server 2012 R2 from home it worked fine. Windows 7 however was affected, and I’m not sure on Windows 8, 8.1 or 10.

This technet post mentions it breaks ‘Conferencing Functionality and PowerPoint Presentations’ as well as ‘ White Boarding, polling’ which was caused by KB3142030. Hoping that was our problem, I uninstalled the update and rebooted – but no luck.

The next check was around .NET framework 4.6.1 which is unsupported on Exchange and Skype for Business Servers (Lync too!) but we didn’t have that installed, due to using the suggested registry setting in the linked article to block the install.

After an evening of troubleshooting and rebooting servers and firewalls that didn’t help, our support found the problem for us – a misconfigured load balancer, that had an incorrect IP for one of the front-end Skype for Business servers. Updating the IP immediately resolved the issue.

Looking back on it, that explains why I had some clients work and not others – it just appeared to be in a pattern that was OS related due to the luck of round robin routing on a load balancer!

Due to the way Skype for Business handles the web requests, by first hitting an edge server then an internal front end server, you may have multiple load balancers in the way and get partial page loading.

Another lesson learnt!

Skype For Business 2016 Client Deployment Tricks

I’ve been mucking around with Skype for Business 2016 and wanted to document what I’ve found.

First, there’s two seperate installs. A standalone Skype for Business 2016, and then as part of the Office 2016 suite, it’s one of the components (just like Word or Excel).

This is important, because if you install the standalone version then try to install Office 2016, it won’t like that Skype for Business is installed already, and tell you to uninstall before continuing. I’m not sure what reason you’d install Skype for Business 2016 standalone if you can just install that single component of Office 2016, but it’s a gotcha that might affect someone down the track.

I’ve also seen a few screen nags after deploying the client. There’s the ‘First things first’ screen which you most likely don’t want users to see:

first things first

To turn this off, set this key to ‘1’:

REG_DWORD: ShownFirstRunOptin
Value: 00000001

Next is the ‘Welcome – Skype for Business’ screen. Can be annoying, and you can just surpress it from running the first time too, but let people read it on demand instead.

welcome to skype

To stop this one showing at first launch, set this key to ‘1’:

REG_DWORD: IsBasicTutorialSeenByUser
Value: 00000001

The final one I saw was after making calls, asking “How was the call quality?”. Most users won’t want to be hassled by this unless there’s an actual problem, so you may want to disable it.

call quality

This setting is actually controlled at the sever end, and has a % chance of showing up after each call. By default, it’s 10%, so I suggest setting it to 0%.

To do so, launch the Skype for Business Server Management Shell and run the commend ‘Get-CSClientPolicy’. This will show you how many policies you have, and you may want to change the value for just some or all, depending which users are against which policy. The field for this setting is called “RateMyCallDisplayPercentage”.

Once you’ve worked out which policy you want to change, run this command: ‘Set-CSClientPolicy -identity “policyname” -RateMyCallDisplayPercentage 0’

If you find any other tricks, feel free to share and I’ll update the post.