Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 Microsoft Lync Server adds another 540 or so to the mix. How in the world can you identify which cmdlets are generic PowerShell cmdlets and which cmdlets belong to Microsoft Lync Server?
And here’s the answer (or at least here’s an answer), 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 cmdlets 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 interest. (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
Anonymous
January 01, 2003
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.)Anonymous
October 22, 2010
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; } }