Friday, April 10, 2015

Everyday Powershell - Part 32 - Create-TaskbarPinnedShortcut

So you may have a need to pin things to taskbars... We Certainly do apparently clicking on the start menu is a step too far for some users... Long and boring story.

Anyway here's some powershell.

$itemstopin = "C:\Program Files (x86)\Microsoft Office\Office15\excel.exe",
"C:\Program Files (x86)\Microsoft Office\Office15\outlook.exe",
"C:\Program Files (x86)\Microsoft Office\Office15\winword.exe"

foreach($item in $itemstopin){
    $path = [system.io.path]::getdirectoryname($item)
    $app = [system.io.path]::getfilename($item)
    $shell = new-object -com "Shell.Application"
    $folder = $shell.Namespace($path
    $item = $folder.Parsename($app)
    $item.InvokeVerb('taskbarpin')
}
All credit goes to this post on stackoverflow http://stackoverflow.com/questions/9739772/how-to-pin-to-taskbar-using-powershell I look at that site and often wonder how many programmers there really are versus how many cut and paste from there.

SOMEONE is writing all this code that the rest of us are copying. Wonder what the ratio really is?