Listing the Microsoft Lync Server 2010 Cmdlets

Listing the Microsoft Lync Server 2010 Cmdlets

  • Comments 2
  • Likes

Here’s a question for you: how can you list just the Microsoft Lync Server cmdlets?

That’s actually a pretty good question. After all, Windows PowerShell ships with some 270+ cmdlets and functions, and then Micro­soft Lync Server adds another 540 or so to the mix. How in the world can you identify which cmdlets are generic Pow­erShell cmdlets and which cmdlets belong to Microsoft Lync Server?

And here’s the answer (or at least here’s an an­swer), a command that returns a list of all the Microsoft Lync Server cmdlets (and only the Microsoft Lync Server cmdlets):

Get-Command -module Lync | More

Ah, but what if you want to see only the cmd­lets that have the word voice somewhere in the cmdlet name? No problem; all you have to do is ask:

Get-Command *voice* -module Lync

Or how about all the Microsoft Lync Server cmdlets that use the verb Get:

 Get-Command -module Lync -verb Get

See how that works? We just include the -Verb parameter followed by the verb of in­terest. (Cmdlet names consist of a verb and a noun: in Get-CsVoicePolicy we have the verb Get and the noun CsVoicePolicy. And before you ask, yes, there is a -Noun parameter as well as -Verb.)

Now here’s a tricky one: what about all the Microsoft Lync Server cmdlets that use the verb Get and that have the word voice somewhere in the cmdlet name? We’ll give you a hint; the following command won’t work:

Get-Command *voice* -module Lync -verb Get

As it turns out, any time you set out to retrieve a specific set of cmdlets (e.g., those that use the verb Get or those that use the noun CsVoicePolicy) you can’t use a wildcard; instead, you have to retrieve all the Get cmdlets or all the CsVoicePolicy cmdlets. In this case, you’re just plain out of luck.

Well, unless you run this command, of course:

Get-Command -module Lync -verb Get| Where-Object {$_.Name -like "*voice*"}

And there you have it.

Comments
  • How does this measure up?

    $teststr = Read-Host;

    ####For Loop to retreive all Cmdlets associated with Lync and process for search string####

    foreach($_ in (Get-Command * | where { ($_.ModuleName -like "*Lync*") -and ($_.CommandType -eq "Cmdlet") }))

    {

       ####Check the help associated with Cmdlet to match with search string####

       if( ((Get-Help $_ -full | Out-String).ToLower()).contains(($teststr.ToString()).ToLower()) )

       {

               Write-Host $_.name;

               }

            }

  • Not bad. This script finds the cmdlets that contain the given input string within the help. Mind if we add it to our list of scripts (blogs.technet.com/.../scripts.aspx)? Send us your name and we'll make sure you get credited too. (You can either add a comment here or send us email: cspshell@microsoft.com.)

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment