fbpx Program: Search the Windows Start Menu in PowerShell | Windows PowerShell, Windows Server | HostingUltraso.com
24/7/365 Support

Program: Search the Windows Start Menu in PowerShell

When working at the command line, you might want to launch a program that is normally found only on your Start menu. While you could certainly click through the Start menu to find it, you could also search the Start menu with a script, as shown in Example 144.

Example 144. SearchStartMenu.ps1

############################################################################## ## ## SearchStartMenu.ps1 ## ## Search the Start Menu for items that match the provided text. This script ## searches both the name (as displayed on the Start Menu itself,) and the ## destination of the link. ## ## ie: ## ## PS >SearchStartMenu "Character Map" | InvokeItem ## PS >SearchStartMenu "network" | SelectFilteredObject | InvokeItem ## ##############################################################################

param( $pattern = $(throw "Please specify a string to search for.") )

## Get the locations of the start menu paths $myStartMenu = [Environment]::GetFolderPath("StartMenu") $shell = NewObject Com WScript.Shell $allStartMenu = $shell.SpecialFolders.Item("AllUsersStartMenu")

## Escape their search term, so that any regular expression ## characters don't affect the search $escapedMatch = [Regex]::Escape($pattern)

## Search for text in the link name dir $myStartMenu *.lnk rec | ? { $_.Name match "$escapedMatch" } dir $allStartMenu *.lnk rec | ? { $_.Name match "$escapedMatch" }

## Search for text in the link destination dir $myStartMenu *.lnk rec | WhereObject { $_ | SelectString "\\[^\\]*$escapedMatch\." Quiet } dir $allStartMenu *.lnk rec | WhereObject { $_ | SelectString "\\[^\\]*$escapedMatch\." Quiet }

Help Category:

Get Windows Dedicated Server

Only reading will not help you, you have to practice it! So get it now.

Processor RAM Storage Server Detail
Processor Intel Atom C2350 1.7 GHz 2c/2t RAM 4 GB DDR3 Storage 1× 1 TB (HDD SATA) Server Detail Configure Server
Processor Intel Atom C2350 1.7 GHz 2c/2t RAM 4 GB DDR3 Storage 1× 128 GB (SSD SATA) Server Detail Configure Server
Processor Intel Atom C2750 2.4 GHz 8c/8t RAM 8 GB DDR3 Storage 1× 1 TB (HDD SATA) Server Detail Configure Server
Processor Intel Xeon E3-1230 v2 3.3 GHz 4c/8t RAM 16 GB DDR3 Storage 1× 256 GB (SSD SATA) Server Detail Configure Server
Processor Intel Atom C2350 1.7 GHz 2c/2t RAM 4 GB DDR3 Storage 1× 250 GB (SSD SATA) Server Detail Configure Server

What Our Clients Say