This blog is part of a series that shows example PowerShell code for those learning the language.
This time we’re using PowerShell to find out which PowerShell cmdlet in a specific module is the most popular. To do this, we’re using a Bing search and producing a list with the name and number of web pages found for each one. This is returned as an object, so you can pipe the output to sort or filter. The name of the module is hard coded to “SmbShare”, but you can replace it with any valid module name. You could also make a parameter.
This example explores using the Internet Explorer objects, searching through web pages by ID, showing cmdlet progress and also a trick to create an object on the fly. It also shows more common items like arrays, string manipulation and functions.
# # # Adds assembly to support URL encoding Function Get-BingCount([string] $Term) { # Add plus and quotes, encodes for URL # Navigate to the Bing page to query the $term # Wait for the page to load # Wait for the document to be ready # Get the count of pages # # Create Internet Explorer object $CmdletList = Get-Command -Module SmbShare | Select Name 0..$CmdletCount | % { # Tracks progress # Check the popularity with Bing Write-Progress -Activity "Checking cmdlet popularity" -Completed # Quit Internet Explorer |
In case you were wondering what the output would look like, here is a sample:









