Nine million turkeys

Can be wrong: Make use of the

TimeRange cmdlet.

 

Yesterday evening, when the author of today's haiku got out of his car, he glanced up at the sky and had a raindrop fall into his half-opened mouth. (Yes, those of us who work here at Microsoft do lead interesting lives, don't we?)

 

To be honest, that wasn't a big deal, nor was it the worst thing he ever had fall into his mouth (for now we'll ignore the okra that he … willingly … ate). A few years ago, he was riding his bike, mouth half-opened again, when a bee flew through the opening and stung him on the inside of the mouth. That was not a whole heck of a lot of fun although, truth be told, it was still better than the okra.

 

Note. Does this suggest that maybe the author of today's haiku should keep his mouth closed more often? Interestingly enough, his wife has been telling him that very thing for years now!

 

At any rate, when the raindrop fell into his mouth, the first thing the author of today's haiku thought about was turkeys. According to American folklore, turkeys are so dumb that, when it starts to rain, they stare up at the sky, mouths half-open in fascination. In fact, turkeys are so fascinated by the rain that they continue to stare up at the sky, their mouths fill up with water, and they drown.

 

So do turkeys really drown in the rain? According to "scientists," no, they don't. However, the author of today's haiku wasn't going to take any chances, so he stopped staring at the sky and immediately went inside.

 

Note. The author of today's haiku is not a scientist. (He's not much of a haiku writer, either, but that's a different story.) On the other hand, there are times when his unfenced backyard resembles a game preserve: he's had every kind of animal from snakes to rabbits to raccoons to squirrels to coyotes in his backyard. And yet, he's never had a turkey in his backyard, never. (He's had several in his oven, but that, too is another story.) It rains all the time in Seattle, and he's never seen a turkey in Seattle. Could that be because all the Seattle turkeys have already drowned? Just a thought …

 

Although the notion that turkeys can actually drown in the rain is still being debated, there's no doubt that turkeys are incredibly dumb animals. How can the author of today's haiku say that? Because of this: even scientists agree that no turkey has ever (ever) used the New-CsRgsTimeRange cmdlet.

 

We kid you not.

 

So why don't turkeys use the New-CsRgsTimeRange cmdlet? That's a good question, and one that even our crack research team here at the Lync Server PowerShell blog has been unable to answer. About all we can tell you at this point in time is that New-CsRgsTimeRange is a must-have cmdlet when you are configuring hours of business for a Response Group workflow. If you aren't familiar with hours of business, those are simply, uh, the hours of business for a workflow, the days and times when agents are available to answer calls. For example, suppose your help desk is staffed from 9:00 AM to 5:00 PM Monday through Friday. In that case, you need to assign those days and times to the workflow.

 

And you can't assign those days and times without first using the New-CsRgsTimeRange cmdlet. Fortunately, New-CsRgsTimeRange is a pretty simple little cmdlet to use: all you have to do is specify an opening time and a closing time, like so:

 

$weekdayHours = New-CsRgsTimeRange –OpenTime "9:00" -CloseTime "17:00"

 

Two things to note here. First, you do need to use the 24-hour clock when setting opening and closing times; as you can see, we set the OpenTime to 9:00 and the CloseTime to 17:00. Suppose we tried using US time settings instead:

 

$weekdayHours = New-CsRgsTimeRange –OpenTime "9:00 AM" -CloseTime "5:00 PM"

 

If we do that, our command will fail and we'll get back this error message:

 

New-CsRgsTimeRange : Cannot bind parameter 'OpenTime', Cannot convert value "9:00 AM" to type "System.TimeSpan". Error: "Input string was not in a correct format."

 

Second, notice that we save the results of running New-CsRgsTimeSpan to a variable ($weekdayHours). Why? Because if we didn't, that time range would disappear as soon as the command finished running. That's important to note: you can't permanently save a time range. That means that every time you create new hours of business you'll need to create a time range to use with those new hours.

 

After you've created your new time range you can then use that range with either the New-CsRgsHoursOfBusiness or the Set-CsRgsHoursOfBusiness cmdlet to configure actual hours of business; after that, those business hours can then be assigned to a workflow. Without going into any detail, here's a command that sets up a new set of business hours called the Help Desk Business Hours:

 

New-CsRgsHoursOfBusiness -Parent Service:ApplicationServer:atl-cs-001.litwareinc.com -Name "Help Desk Business Hours" -MondayHours1 $weekdayHours -TuesdayHours1 $weekdayHours -WednesdayHours1 $weekdayHours  -ThursdayHours1 $weekdayHours  -FridayHours1 $weekdayHours

 

If you take a minute to look at that command, you'll see that we have a parameter for each weekday, Monday through Friday. For each of those weekdays, we've then set the hours to the variable $weekdayHours, the variable we created using New-CsRgsTimeRange. And then, just to ensure we have a happy ending today, we could then assign these business hours to a workflow:

 

$businessHours = Get-CsRgsHoursOfBusiness service:ApplicationServer:atl-cs-001.litwareinc.com -Name "Help Desk Business Hours"

$y = Get-CsRgsWorkflow Service:ApplicationServer:atl-cs-001.litwareinc.com -Name "Help Desk Workflow"

$y.BusinessHoursId = $businessHours.Identity

Set-CsRgsWorkflow -Instance $y

 

That's all there is to it.

 

Incidentally, the author of today's haiku has learned that a researcher at Oregon State University believes that turkeys really do occasionally stop and stare blankly into space for a minute or so. However, this isn't because they are dumb, but because they suffer from a genetic disorder known as tetanic torticollar spasms. In looking this up (hey, it's better than working right?) the author of today's haiku learned that torticollis (also known as "wry neck") is a malady in which the head is twisted to one side, with the chin pointing up; tetanic refers to a muscular contraction. So do tetanic torticollar spasms explain why the author of today's haiku often walks around with his mouth half-open, staring blankly into space? It does now!