PowerTip: Use PowerShell to Find Example Code

Doctor Scripto

Dr Scripto

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} 

Doctor Scripto
Dr Scripto

Scripter, PowerShell, vbScript, BAT, CMD

Follow Dr Scripto   


    Leave a comment