I love tips that make my work easier. I got this neat idea from reading Mike F. Robbins’s blog. Mike has a tip on how to learn a new PowerShell cmdlet every day. Its easy – just run the following line of PowerShell every morning:
Get-Command | Get-Random | Get-Help –Full
I normally keep the Lync, ActiveDirectory and LyncOnline modules loaded in my editor so the code can pull a cmdlet from those or any other loaded module. I know that Lync alone has over 500 cmdlets so I should have a couple years worth of learning here. May have to double up and run the command in the evening also.
Sample output
I ran it several times this morning and got help for several different cmdlets. The output looks like what is shown below for Remove-CsVoiceRoute.
NAME
Remove-CsVoiceRoute
SYNOPSIS
Removes a voice route. Voice routes contain instructions that tell Microsoft Lync Server 2010 how to route calls from Enterprise Voice us
ers to phone numbers on the public switched telephone network (PSTN) or a private branch exchange (PBX).
SYNTAX
Remove-CsVoiceRoute -Identity <XdsGlobalRelativeIdentity> [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-WhatIf [<SwitchPara
meter>]] [<CommonParameters>]
DESCRIPTION
Use this cmdlet to remove an existing voice route. Voice routes are associated with voice policies through PSTN usages, so removing a voi
ce route does not change any values relating to a voice policy, it simply changes the routing for the numbers that had matched the patter
n for the deleted voice route.
Who can run this cmdlet: By default, members of the following groups are authorized to run the Remove-CsVoiceRoute cmdlet locally: RTCUni
versalServerAdmins. To return a list of all the role-based access control (RBAC) roles this cmdlet has been assigned to (including any cu
stom RBAC roles you have created yourself), run the following command from the Windows PowerShell prompt:
Get-CsAdminRole | Where-Object {$_.Cmdlets -match "Remove-CsVoiceRoute"}
PARAMETERS
-Identity <XdsGlobalRelativeIdentity>
A string that uniquely identifies the voice route you want to delete. (If the route name contains a space, such as Test Route, you mu
st enclose the full string in double quotes.)
Required? true
Position? 2
Default value
Accept pipeline input? True
Accept wildcard characters? false
-Force <SwitchParameter>
Suppresses any confirmation prompts that would otherwise be displayed before making changes.
Required? false
Position? Named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actually executing the command.
Required? false
Position? Named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.
Required? false
Position? Named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".
INPUTS
Microsoft.Rtc.Management.WritableConfig.Policy.Voice.Route object. Accepts pipelined input of voice route objects.
OUTPUTS
Removes an object of type Microsoft.Rtc.Management.WritableConfig.Policy.Voice.Route.
-------------------------- Example 1 --------------------------
Remove-CsVoiceRoute -Identity Route1
Removes the settings for the voice route with the identity Route1.
-------------------------- Example 2 --------------------------
Get-CsVoiceRoute | Remove-CsVoiceRoute
This command removes all voice routes from the organization. First all voice routes are retrieved by the Get-CsVoiceRoute cmdlet. These v
oice routes are then piped to Remove-CsVoiceRoute, which removes each one.
-------------------------- Example 3 --------------------------
Get-CsVoiceRoute -Filter *Redmond* | Remove-CsVoiceRoute
This command removes all voice routes with an identity that includes the string "Redmond." First the Get-CsVoiceRoute cmdlet is called wi
th the Filter parameter. The value of the Filter parameter is the string Redmond surrounded by wildcard characters (*), which specifies t
hat the string can be anywhere within the Identity. After all of the voice routes with identities that include the string Redmond are ret
rieved, these voice routes are piped to Remove-CsVoiceRoute, which removes each one.
RELATED LINKS
Online Version http://technet.microsoft.com/EN-US/library/6687e538-e8f6-4bf0-b393-2c7b4a3f2f06(OCS.14).aspx
I hope you found this helpful. Feel free to comment or contact me if you have questions.
[...] Cool PowerShell Tip for Learning Lync Cmdlets | GotSpeechGuy Posted on June 28, 2012 by johnacook http://gotspeechguy.com/2012/06/28/cool-powershell-tip-for-learning-lync-cmdl… [...]
Wonderful way to learn powershell, and not only Lync
You can refine this to just get Lync cmdlets like this:
Get-Command *-CS* | Get-Random | Get-Help -Full
Or to just get Active Directory cmdlets:
Get-Command *-AD* | Get-Random | Get-Help -Full
Thanks Microsoft for using a consistant naming convention.