September 26th, 2013

PowerTip: Use PowerShell to Find Example Code

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to find easy-to-use example code.

Hey, Scripting Guy! Question How can I find examples of using Windows PowerShell cmdlets and functions—in particular examples that begin with the verb Get?

Hey, Scripting Guy! Answer Use the Get-Command cmdlet to find commands beginning with the verb Get, pipe the results to the Foreach-Object cmdlet, and call Get-Help on each item.

For Windows PowerShell 4.0 and Windows PowerShell 3.0:

(Get-Command -Verb get).name | foreach {get-help $psitem -example}

For Windows PowerShell 2.0 and on Windows PowerShell 1.0:

Get-Command -Verb get | foreach {get-help $_.name -example} 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.