New-DeskTopShortCut.ps1


<#PSScriptInfo
 
.VERSION 1.0.0.0
 
.GUID 59b70700-c6a8-44c9-970c-cccaeb46bc4b
 
.AUTHOR Jeffrey Snover
 
.COMPANYNAME
 
.COPYRIGHT
 
.TAGS
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
#>


<#
 
.DESCRIPTION
 Create a desktop shortcut
 
#>
 
Param(
[Parameter(Position=0,Mandatory=1)]
$Name,
[Parameter()]
[ValidateSet("lnk","url")]
$Type = "lnk",
[Parameter(Position=1,Mandatory=1)]
$Path
)

$ShortCutName        = Join-Path ([Environment]::GetFolderPath("Desktop")) "$Name.$Type"
$ShortCut            = (New-Object -ComObject WScript.Shell).CreateShortcut($ShortCutName)
$ShortCut.TargetPath = $Path
$ShortCut.Save()