-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGet-StartMenu.ps1
34 lines (32 loc) · 1.11 KB
/
Get-StartMenu.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#requires -Version 2
# PowerShell function to list Start Menu Shortcuts
# http://www.computerperformance.co.uk/powershell/powershell_function_shortcut.htm#Putting_it_all_together_-_List_Shortcuts_and_Targets
Function Get-StartMenu
{
Begin{
Clear-Host
$Path = "$Env:ProgramData\Microsoft\Windows\Start Menu\Programs"
$x = 0
} # End of Begin
Process {
$StartMenu = Get-ChildItem $Path -Recurse -Include *.lnk
ForEach($ShortCut in $StartMenu)
{
$Shell = New-Object -ComObject WScript.Shell
$Properties = @{
ShortcutName = $ShortCut.Name
LinkTarget = $Shell.CreateShortcut($ShortCut).targetpath
}
New-Object -TypeName PSObject -Property $Properties
$x ++
} #End of ForEach
$null = [Runtime.InteropServices.Marshal]::ReleaseComObject($Shell)
} # End of Process
End{
"`nStart Menu items = $x "
}
}
#Example of function in action:
Get-StartMenu |
Sort-Object -Property ShortcutName |
Format-Table -Property ShortcutName, LinkTarget -AutoSize