Microsoft Lync Server 2010 provides two cmdlets –
– that return information about user accounts. (Get-CsUser returns information only for user accounts that have been enabled for Lync Server; Get-CsAdUser returns information for
your Active Directory user accounts, regardless of whether those accounts have been enabled for Lync Server.) Because administrators often want to work with all the accounts found in an organizational unit, both of these cmdlets include a –OU parameter; when included in a command, this parameter causes the cmdlet to return all the user accounts found in the specified OU, as well as any child OUs. For example, this command returns information about all the user accounts in the Redmond OU:
So what’s wrong with that? Nothing; the cmdlet – and the
parameter – work great. However, there
one possible catch here. (Yes, we know. But when
there at least one possible catch?) Suppose the Redmond OU has a child OU, an OU named Finance (ou=Finance,ou=Redmond,dc=litwareinc,dc=com) . Let’s pretend the two OUs – and their user accounts – look like this:
Let’s further pretend that we’ve just run this command:
Here are the display names that get returned when we run the command:
As you can see, we get back the names of the two users in the Redmond OU (Ken Myer and Pilar Ackerman). However, we also get back the names of the two users in the Finance OU (Jonathan Haas and Kim Abercrombie).
And that’s the potential problem: what if we don’t
the users from the child OU? What if we only want the users found in the parent OU (Redmond)?
If you’re thinking, “I bet this is the place where they show us the cool little trick that causes the –OU parameter to ignore child OUs when returning data,” well, we’re afraid you might be a little disappointed: as far as we know, there
any trick that can do that. To the best of our knowledge, you can’t directly use Get-CsUser or Get-CsAdUser to return information from a parent OU while ignoring any child OUs; the cmdlets just aren’t built that way. However, you
return data from a single OU by using a Windows PowerShell script similar to this one: