blog.powershell.no

On Windows PowerShell and other admin-related topics

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:

image 
(Option 1)

image
(Option 2)

The module consist of one function as shown here:

image

The help text are available with Get-Help:

image

For example usage, add –Examples to the Get-Help cmdlet:

image

Basic error checking for valid parameters are included:

image

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.


February 26, 2010 - Posted by Jan Egil Ring | Desktop management, Windows 7, Windows PowerShell, Windows Server 2008 R2 |

1 Comment »

  1. 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.

    Comment by Thomas Christiansen | July 13, 2010 | Reply


Leave a comment