Blog Post

Skype for Business Blog
5 MIN READ

Haiku #71

NextHop_Team's avatar
NextHop_Team
Brass Contributor
May 20, 2019
First published on TECHNET on Mar 21, 2011

Some things we are not

Meant to know. For others, there's

Get-CsService.

There is a series of commercials playing on American TV these days in which some dorky guy walks up to a bar and asks the bartender for a light beer. The bartender asks if he'd like a good-tasting beer or a lousy-tasting beer, and the dorky guy always picks the lousy-tasting beer. (Always.) In turn, the bartender makes fun of the guy, and the narrator tells the guy to "Man up!" because, apparently, the mark of a real man these days is one who prefers good-tasting beer to lousy-tasting beer. Want to be a real man? Then drink a good-tasting beer rather than a lousy-tasting beer. That's all you have to do.


Note . Which is actually a change for the better. After all, back in the old days, the only way to be a real man was to lead a wagon train across the Continental Divide, or maybe kill a grizzly bear with your bare hands. Now you just have to correctly answer a single question: would you rather drink something that tastes good or something that tastes lousy? There's hope for the author of today's Lync Server PowerShell haiku after all! (Although, just to be on the safe side, he's had the correct answer – a good-tasting beer – tattooed onto the palm of his hand.)


These commercials are so much fun we decided to steal the idea and use it in today's article. (To be perfectly honest, we base many of our real-life actions on what we see in beer commercials.) With that in mind, here's the question of the day: would you rather return information about Lync Server services using a lousy cmdlet that doesn't even work and probably doesn't even exist, or would you rather return information about Lync Server services using the Get-CsService cmdlet?

If you answered "I'd rather return information about Lync Server services using the Get-CsService cmdlet" then congratulations: you're a real man! Way to go!


Note . What if you're not a man at all, but a woman? Well, for some reason, the men in beer commercials often look like complete idiots and need to be reassured that they're not all that stupid; the women generally come off looking much smarter and much more competent. And yes, we've often wondered what that has to do with real life, too.



Oh, wait, never mind. The more we think about it, and the more we think about the guys (and women) we know, the more we understand what that has to do with real life. Like we said, never mind.


Now that you've "manned up" and chosen the Get-CsService cmdlet, it might help if you know a little bit about the Get-CsService cmdlet. (Although, speaking as a member of the male species, this author knows that not knowing the least bit about what he’s talking about has never stopped him from going ahead and doing something anyway.) As we noted, Get-CsService is used to return information about your Lync Server services and server roles. In its simplest form, you can call Get-CsService without any parameters and get back information on all your Lync Server services and server roles:

Get-CsService

But hey, as most women will attest, when do real men ever do anything in a simple, easy, common-sense fashion? If you want to do something a little fancier, Get-CsService also has a number of parameters that let you zero in on more specific services or server roles. For example, would you like information about all your PSTN gateways? That's fine; just use tack on the –PstnGateway parameter, like so:

Get-CsService –PstnGateway

Pretty cool, huh? As it turns out, Get-CsService has a ton of parameters that allow you to return information about just your Mediation servers or just your user databases or just your Monitoring servers. How do you know what parameters are available to you (and, by extension, what services and server roles you can return)? Well, one way is to look at the help topic for Get-CsService; that never hurts. However, on the off chance that it does hurt to look at the help (and we have to admit every now and then reading help files has given us a headache) then you can always run this command and get back a list of Get-CsService parameters:

Get-Command Get-CsService | Select-Object –ExpandProperty Parameters

But let's see if we can get really fancy. Suppose you'd like information about both your PSTN gateways and your Mediation servers. Here's the second question of the day: is this command going to work:

Get-CsService –PstnGateway –MediationServer

Ooh, sorry, that is not correct. If you run the preceding command you're going to get back this error message:

Get-CsService : Parameter set cannot be resolved using the specified name parameters.

And yes, that is a good example of help that can give you a headache. What it really means, however, is simple: Get-CsService won't allow you to combine parameters that specify different services or server roles. (Why not? That's just the way the cmdlet works.) If you want to use a single command to get back information about multiple services or server roles you need to get a little sneaky, like so:

Get-CsService | Where-Object {$_.Role –eq "PstnGateway" –or $_.Role –eq "MediationServer"}

As you can see, what we need to do is return all the services and server roles, then pipe that data to the Where-Object cmdlet; we then ask Where-Object to pick out only those items where the Role property is equal to PstnGateway or MediationServer . A little extra typing (and a little extra thinking) is required, but it will work.


Note . So how the heck are you supposed to know the names of all the service/server roles? Running this command should help:



Get-CsService | Select-Object Identity, Role


Here's another useful little command. As you probably know, many Lync Server services and server roles have dependent services. Which ones have dependent services? This command will tell you:

Get-CsService | Where-Object {$_.DependentServiceList.Count –ne 0} | Select-Object Identity

And this command tells you which services or server roles don't have dependent services:

Get-CsService | Where-Object {$_.DependentServiceList.Count -eq 0} | Select-Object Identity

Is that cool or what?

Incidentally, we should point out that Get-CsService is a read-only cmdlet: there is no corresponding Set-CsService cmdlet that lets you modify service/server role properties. So what are you supposed to do if you need to change the SIP port for one of your Directors? Well, in that case, you're going to need to use the Set-CsDirector cmdlet, just like you need to use the Set-CsMonitoringServer cmdlet if you need to make a change to your Monitoring server configuration. It's not exactly the ideal solution but hey, which would you rather have: the ideal situation or a less-than-ideal situation?

Thatta way: spoken like a real man!

See you tomorrow.


Updated May 20, 2019
Version 2.0
No CommentsBe the first to comment