Friday, 30 March 2012

Pin shortcuts to the taskbar with Powershell

In this script I pin Word, Excel and Powerpoint to the taskbar.

You could modify it to pin any other shortcuts.

Be aware that this is for Windows 7/8/8.x and english only.

$shell = New-Object -ComObject Shell.Application
$programsFolder = $shell.Namespace(23).Self.Path

$officeFolder = $shell.Namespace($programsFolder + "\Microsoft Office")

$excel = "Microsoft Excel 2010.lnk"

$word = "Microsoft Word 2010.lnk"

$powerpoint = "Microsoft PowerPoint 2010.lnk"

$office = @($word,$excel,$powerpoint)

foreach($_ in $office){

($officeFolder.ParseName($_).verbs() | ? {$_.Name -match "Tas&kbar"}).Doit()

}


If you want to pin shortcuts during a image build or deployment then you can use Active Setup.

First make sure you save the script above as PinToTaskBar.ps1 and place it in the script folder of the MDT Toolkit.

Now create 3 Run Command Line steps in your task sequence.

cmd /c reg add "HKLM\Software\Microsoft\Active Setup\Installed Components\PinTaskBar"

cmd /c reg add "HKLM\Software\Microsoft\Active Setup\Installed Components\PinTaskBar" /v StubPath /t REG_SZ /d "C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -File %SCRIPTROOT%\PinToTaskBar.ps1" /f

cmd /c reg add "HKLM\Software\Microsoft\Active Setup\Installed Components\PinTaskBar" /v Version /t REG_SZ /d 1 /f

2 comments:

  1. Are there any possibilities to create a script for windows8/server2012 to deploy by GPO?

    Thx

    ReplyDelete
  2. Hi Maurice,

    This script works fine with Windows 8 and 2012 as well.

    Just choose your preferred method to deploy it.

    You could use a ESD, GPO, GPP and so on.

    Cheers

    ReplyDelete