Get-CsUser Filter Parameter and Enabled Attribute

Aren’t the Filter parameter and the Enabled attribute on the Get-CsUser cmdlet redundant? Doesn't Get-CsUser always return all the users who have been enabled for Lync Server?

Yes, Get-CsUser always returns all the users who have been enabled for Lync Server.

Except, of course, when it doesn't.

What do we mean by that? Here's what we mean by that. When you install Lync Server, the Enabled attribute is added to each of your user accounts. As shown in the table of users below, that attribute can have one of three possible values:

User

Account Status

Enabled Attribute

Ken Myer

Enabled for Lync Server

$True

Pilar Ackerman

Lync Server account temporarily disabled

$False

April Reagan

Not enabled for Lync Server

$Null

As you can see, both Ken Myer and Pilar Ackerman have been enabled for Lync Server. However, Ken's Lync Server account is active, which means he can use that account to log on to Lync Server. Pilar's account, by contrast, has been temporarily disabled: it's a valid Lync Server account, but she can't currently use that account to log on to Lync Server. How do we know whether a Lync Server account can be used or not? That's easy: if the Enabled attribute is True then the account can be used. If the Enabled attribute is False, then it can't be used, at least not at the moment.

Note. And if you've not enabled for Lync Server, like poor April Reagan, then your Enabled attribute will be set to a Null value. For more information, see the article When is a Boolean Not a Boolean?

So what does all that have to do with the Get-CsUser cmdlet and the Filter parameter? Well, called by itself, Get-CsUser returns all the users who have been enabled for Lync Server, regardless of whether or not their account is active. Consider this command, which returns the DisplayName and Enabled attribute values for all your Lync Server users:

Get-CsUser | Select-Object DisplayName, Enabled

That's going to return data that looks like this:

DisplayName Enabled

----------- -------

Ken Myer True

Pilar Ackerman False

Now, suppose we're interested only in Lync-enabled users who have active accounts. That's where the Filter parameter and the Enabled attribute come in handy:

Get-CsUser –Filter {Enabled –eq $True} | Select-Object DisplayName, Enabled

Like we said, we're interested only in those Lync-enabled users who can actually log on to the system. That means that the command we just showed you should filter out Pilar Ackerman and, lo and behold, it does:

DisplayName Enabled

----------- -------

Ken Myer True

Or we can go the other direction, and look at only those Lync-enabled users who can't currently log on to the system?

Get-CsUser –Filter {Enabled –eq $False} | Select-Object DisplayName, Enabled

That seems to work, too:

DisplayName Enabled

----------- -------

Pilar Ackerman False

Note. Actually it doesn't just seem to work, it does work.

Which simply means this: the Filter parameter, and the Enabled property, is very useful if you need to draw a distinction between Lync-enabled users who have active accounts and Lync-enabled users who have inactive accounts. If you don't need to draw that distinction then you don't need to use the Filter parameter and the Enabled property.

Make sense? We figured it would.