Create PowerShell Shortcuts

If you ever wanted to create shortcut icons on your Desktop, or in your programs menu, to quickly launch PowerShell, here is a way to do it:

function CreatePSShortcut {
$wshell = New-Object -comObject WScript.Shell
$path1 = $wshell.SpecialFolders.Item('Desktop')
$path2 = $wshell.SpecialFolders.Item('Programs')

$path1, $path2 | ForEach-Object {
$link = $wshell.CreateShortcut("$_\PowerShell.lnk")
$link.TargetPath = 'powershell.exe'
$link.Description = 'launches Windows PowerShell console'
$link.WorkingDirectory = $home
$link.IconLocation = 'powershell.exe'
$link.Save()
}
}

CreatePSShortcut

Of course, you can use this code template to create just about any shortcut you want. Simply adjust the Target and IconLocation properties to point to the program that the shortcut should launch.


Posted Apr 20 2009, 08:00 AM by ps1

Comments

rdottd wrote re: Create PowerShell Shortcuts
on 07-27-2011 10:53 AM

what does $_ mean in powershell?

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.