Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Monday, July 8, 2013

Search a PowerShell Module’s Help Files for Key Words

This past week I have been working on a project in Windows Azure and PowerShell.  As I’m learning the Azure platform, I’m coming across the need to be able to find key words in the help files to help me discover the cmdlets that I need.  Here is the command line that I am using.

Get-Command -Module Azure | ForEach-object -process {Get-help $_.name -Detailed} | Select-ObjectProperty Name, Description | Where-Object Description -like "*blob*" | Select-ObjectProperty Name

 

The –Module parameter is used to ensure the Get-Command cmdlet only returns objects from the Azure module.

 

The ForEach-Object cmdlet will cycle through each cmdlet and call the detailed help file for each cmdlet.

 

We can filter some of our data at this point and ask for only the cmdlet’s name and description.

 

Finally, the Where-Object cmdlet is used to look for a pattern.  In this case, I am looking for any help file from the Azure module that has the work “blob” in it.

 

Optionally, I added one more Select-Object filter to give me only the name of the cmdlet.

 

PS C:\> Get-Command -Module Azure |

ForEach-object -process {Get-help $_.name -Detailed} |

Select-Object -Property Name, Description |

Where-Object Description -like "*blob*" |

Select-Object -Property Name

 

Name                                                                                                   ----

Start-AzureStorageBlobCopy

Stop-AzureStorageBlobCopy 

Add-AzureDataDisk

Add-AzureVhd

Get-AzureStorageBlob

Get-AzureStorageBlobContent

Get-AzureStorageBlobCopyState

New-AzureStorageAccount

Remove-AzureDataDisk

Remove-AzureDisk

Remove-AzureStorageBlob

Remove-AzureVMImage

Save-AzureVhd

Set-AzureStorageBlobContent

Start-AzureStorageBlobCopy

Stop-AzureStorageBlobCopy

At this point, I can now look for a verb/noun combination that looks good and investigate the individual help file.

No comments: