Haiku #110
Published May 20 2019 03:33 PM 1,176 Views
Occasional Visitor
First published on TECHNET on May 13, 2011

Friday the 13 th ?

So what? Just carry salt and

Clear device updates.

In case you haven't bothered to check a calendar recently, today is Friday the 13 th . As you probably know, many people in the Western world consider Friday the 13 th to be a day when bad luck is almost certain to befall you. Is that really true? Is today going to be an unlucky day? To be honest, we don't think so. After all, you've been given the chance to read yet another Lync Server PowerShell Haiku of the Day. Does that sound like bad luck to you?

Note . That was a rhetorical question. You weren't supposed to answer it.

Interestingly enough, no one is totally sure why Friday the 13 th is considered such an unlucky day. Many people blame Norse mythology but, then again, many people blame Norse mythology for everything these days. High unemployment rate? That's because the Frigga lost her job as the Norse goddess of love and fertility and was banished to a mountaintop.

Which, come to think, makes as much sense as any other reason we've heard.

Note . Interesting fact. If a month starts on a Sunday, that means that there will be a Friday the 13 th during that month. (Most likely on the 13 th of the month.) Why is that interesting? Hey, when you write Lync Server PowerShell haikus for a living pretty much anything seems interesting.

Other people suggest that our fear of Friday the 13 th is rooted in Christian beliefs and folklore; for example, it has been suggested that Eve gave Adam an apple on Friday the 13 th . We're not totally sure how people know that Eve gave Adam the apple on Friday the 13th, but maybe one day archeologists will uncover her diary and then we'll know for sure:

Friday, May 13 th .

Dear Diary. I gave Adam an apple today. He seemed to like it, and what harm could a little apple cause?

Those of us who work at the Lync Server PowerShell blog don't find Friday the 13 th to be particularly unlucky: for us, it's no different than any other day. (You can take that any way you want to take it.) For those of you who are a little uncertain about Friday the 13 th , it's recommended that you carry a talisman around to protect you from evil spirits. (A talisman is, uh, something you carry around to protect you from evil spirits.) But don't think a rabbit's foot or a four-leaf clover will do the trick. You need a real talisman. For example, you should carry one of the following in your pocket:

· Hematite (An iron oxide that crystallizes in the rhombohedral system, and it has the same crystal structure as ilmenite and corundum. Or so they say, anyway.)

· Moonstone (A sodium potassium aluminum silicate. As if we had to tell you that.)

· Sea salt (This is just a wild guess, but we believe this is salt from the sea.)

Of course, some of you might be a bit reluctant to walk around all day with a pocketful of salt. (Actually, A Pocketful of Salt would be a good title for a novel, wouldn't it?) In that case, we recommend you do what the ancient Norse used to do to ward off evil: run the Clear-CsDeviceUpdateFile cmdlet.

So how does Clear-CsDeviceUpdateFile ward off evil? Well, to be honest, we're not totally sure. (But, then again, we're not totally sure how carrying around a pocketful of salt wards off evil, either. The world is a mysterious place, eh?) What we do know is this: Each time you upload new device updates to Lync Server, a device update rule is created for each device included in the update. These device update rules are automatically marked as Pending; that means that the rules can be downloaded and installed on test devices, but not on production devices (that is, not on the devices your users are actually carrying around and using). Why do we mark new rules as Pending? We actually have a good reason for that: that gives you a chance to test those updates before you spring them on your users. If all goes well, you can then run the Approve-CsDeviceUpdateRule cmdlet to make these device updates available to everyone.

All in all, a pretty good way of doing things.

But let's suppose that things don't go well; let's suppose that you install these updates on your test devices and those test devices no longer work as expected. What do you do then? Well, in that case you can use the Reset-CsDeviceUpdateRule or the Restore-CsDeviceUpdateRule cmdlets to reject one or more of the updates. At that point, the device update is unchained from its device update rule. In turn, that means you can then run Clear-CsDeviceUpdateFile to delete these unchained update files from the server. That prevents your server from being cluttered with device updates that you have no intention of ever using.

Which, again, is a pretty good way of doing things.

So how exactly do you use the Clear-CsDeviceUpdateFile cmdlet? The same way the Norse used to use it: by calling the cmdlet followed by the location of the device update files to be removed. (Device update files are always uploaded to a computer running the Web server service.) For example:

Clear-CsDeviceUpdateFile -Identity "service:WebServer:atl-cs-001.litwareinc.com"

That's pretty much all you have to do. You don't even have to specify which files to remove; Clear-CsDeviceUpdateFile can figure that out for itself simply by looking for files no longer associated with a device update rule.

Now, suppose you want to clean up all your Web servers. At first that might seem to be a bit of a problem; after all, the Clear-CsDeviceUpdateFile cmdlet doesn't accept pipelined input. That means that a command like this one, which used Get-CsService to grab a collection of all your Web servers and then tries to pipe that collection to Clear-CsDeviceUpdateFile isn't going to work:

Get-CsService –WebServer | Clear-CsDeviceUpdateFile

Fortunately, there's a way to work around this problem: you simply pipe the data to the ForEach-Object cmdlet instead, and then let ForEach-Object take care of things for you. This command will clean up all your Web servers:

Get-CsService –WebServer | ForEach-Object {Clear-CsDeviceUpdateFile –Identity $_.Identity}

Which, as far as we know, is exactly how Frigga used to clean up her Web server. At least before she was banished to a mountaintop and labeled a witch.

Will you be banished to a mountaintop and labeled a witch if you run the Clear-CsDeviceUpdateFile cmdlet? Well, we haven't heard of that happening to anyone yet, so we're going to say no. Still, you might want to toss a little sea salt in your pocket, just in case. Or better yet, take the rest of the day off, and wait until Monday the 16 th to run Clear-CsDeviceUpdateFile. You can never be too careful now, can you?

Version history
Last update:
‎May 20 2019 03:33 PM
Updated by: