Pin and unpin applications from the taskbar and Start-menu using Windows PowerShell
I`ve created a PowerShell module for working with pinned applications in Windows 7 and Windows Server 2008 R2. The module are created based on a script created by Ragnar Harper and Kristian Svantorp.
The module are available here, on the TechNet Script Center Gallery.
Installation and usage
Modules in Windows PowerShell can be “installed” in two ways:
1) Save the module as a psm1-file, and store it in a folder with the same name as the psm1-file. Copy this folder, using i.e. xcopy or Copy-Item, to a desired PowerShell module-folder (see available module paths using $env:PSModulePath)
2) Import the module by calling the psm1-file directly.
The first option are preferred for production use.
Next, import the module using Import-Module:
The module consist of one function as shown here:
The help text are available with Get-Help:
For example usage, add –Examples to the Get-Help cmdlet:
Basic error checking for valid parameters are included:
The Set-PinnedApplication function supports the en-us and nb-no locales as-is, but you can easily add support for more locales.
Feel free to let me know in the comment section below if you got any feedback.
Update, 06.08.2010: A new version of the module are now published at the original link on the TechNet Script Center Gallery. In the new version, there are full MUI support, after an update by Johan Akerstrom.





Very nice module.
I have one problem though. I cant pin an application with a parameter.
For example:
Set-PinnedApplication -Action PinToTaskbar -FilePath “c:\windows\explorer.exe h:\”
This returns:
Test-Path : The given path’s format is not supported.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PinnedApplications\PinnedApplications.psm1:60 char:26
+ if(-not (test-path <<<< $FilePath)) { write-warning "`nPath does not exist.`n $FilePath `nExiting… `n"; return }
+ CategoryInfo : InvalidOperation: (C:\windows\explorer.exe h:\:String) [Test-Path], NotSupportedException
+ FullyQualifiedErrorId : ItemExistsNotSupportedError,Microsoft.PowerShell.Commands.TestPathCommand
WARNING:
Path does not exist.
c:\windows\explorer.exe h:\
Exiting…
Do you know of any solution to this?
Thanks.
Thomas, this is due to Test-Path exepecting a filepath without any additional data.
To suit your needs you might have to tweak the module a little bit.
Thanks a lot, it worked flawlessly to pin outlook
Great script! Makes Windows 7 deployment desktops much more tidy.
Is it possible to pin to all users?
Thanks
Thanks! I haven`t thought of that, but I guess modifying the default user profile should work: http://support.microsoft.com/kb/973289
How to make possible in a way -FilePath to specify a variable?\
For example so
Set-PinnedApplication-Action PinToTaskbar-FilePath %ProgramFiles%\Google\Chrome\Application\chrome.exe
Hi,
In PowerShell we can use the $env: variable to access environment variables. I.e. $env:ProgramFiles\Google\Chrome\Application\chrome.exe
Is there a way we can pin non-exe files to the Start menu as well? I understand that you go through the verbs , find the “Pin to start menu” option and execute it. This option only appears for .exe files. (I know that if you shift+ right click , you will see these alternative actions for non-exe files.)
Honestly I don`t know, but I`d guess it`s possible since you can do it manually by using shift+right click. I`ll let you know if I find out.
I need to set a pinned icon that launches two executables, e.g. “C:\Program Files\SIMS\SIMS .net\SIMSLoad.exe” “C:\Program Files\SIMS\SIMS .net\Pulsar.exe”, is it possible to do this?
To be able to launch several exe-files I guess you`d have to put them in a cmd/bat-file. I haven`t tested pinning cmd/bat-files, however it is possible to do it manually when holding Shift + right click on the file so it should also be possible to automate the process.
Must this script run every time the user logs in??
Where should the *.psm1 file live so it can be called by a logon.bat script when people log in to a XenApp server??
Thank you, tom
No, you could run it only once per user if needed. However if the user unpins a program the program won`t be re-pinned if the script is`n run for every logon.
You can place the psm1–file in the following folder on a terminalserver: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PinnedApplications
1) If I run it each time the user logs in will it pin the app multiple times to their taskbar and start menu??
2) I notice your path says ’1.0′, our XenApp servers are Windows 2008 R2 SP1, should it be ’2.0′??
I assume this module gets placed into each of our XenApp servers.
Our current login script applies to all domain users on several different Windows OSes — it only maps network drives and can’t be taken out etc.
3) Should I learn how to make this module/script run ONLY when they are logging into one of our XenApp servers??
Otherwise XP or 2003 will throw errors when they can’t execute the module??
4) Will this module work if I specify a shortcut instead of an *.exe?? (I don’t need people getting messages about Office needing to install things, smile, we just want to pin IE, word 2010, excel 2010, outlook 2010 to both taskbar and start menu plus windows explorer to start menu only)
This blog appears to say shortcuts are better to use:
http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx
“Update 28 April 2009 – This post originally had the sample scripts pinning the executable (calc.exe) directly. A colleague of mine pointed out that it would be better to pin the Start Menu shortcuts for items instead of directly pinning the executable. This should be done because shortcuts for Windows Installer applications are special. Launching applications using their Windows Installer shortcuts can, for example, initiate a repair of the application it if is needed. So I have changed all the samples to point to shortcuts. I have also rewritten the attached script as an MDT script and add added a function library that allows the CSIDL (constant special item ID list) values for “special” folders to be used a variables in the item path.”
Thank you for taking time to respond…your script is easier than the one in the blog if I can get it to work properly…
Thank you, Tom
1) No, it get`s pinned only once.
2) No, the path is still “1.0″ for PowerShell 2.0 which is integrated in Windows Server 2008 R2.
3) Yes, if not you would have to distribute the module to the clients as well (can be scripted)
4) Yes, lnk-files can be pinned.
Thank you!!
I have asked on powershellcommunity forum how I can check for which server/computer is being logged into to deal with that issue.
As to un-pin, maybe there’s something in group policy to prevent unpinning but allow pinning.
Thank you, Tom
[...] http://blog.powershell.no/2010/02/26/pin-and-unpin-applications-from-the-taskbar-and-start-menu-usin... [...]
Pingback by HowTo: Per Gruppenrichtlinie und PowerShell Taskleiste Elemente anheften und lösen | dertechblog | November 9, 2011 |