$Path = @("C:\Windows\system32\notepad.exe","C:\Windows\System32\shutdown.exe")
$Desktop = (New-Object -ComObject Shell.Application).NameSpace(0X0)
Foreach($itemPath in $Path){Foreach($ItemVerb in (($Desktop.ParseName($itemPath)).Verbs())){If($ItemVerb.Name.Replace("&","") -match "Pin to Taskbar"){$ItemVerb.DoIt()}}}
This is 3 lines of love for the taskbar. If you switch the 'match' to 'Pin to Start Menu' the magic moves to the start menu. Happy pinning.
Good stuff, Pat. I'll be emailing this to a couple of friends.
ReplyDelete