Functions/New-Shortcut.ps1


function New-Shortcut {
    param (
        [parameter(mandatory=$true)][string]$ShortcutLocation,
        [parameter(mandatory=$true)][string]$ShortcutTarget,
        [string]$Arguments,
        [string]$IconLocation
    )

    $WshShell = New-Object -ComObject WScript.Shell

    $Shortcut = $WshShell.CreateShortcut($ShortcutLocation)
    if($Arguments) {
        $Shortcut.Arguments = $Arguments
    }
    $Shortcut.TargetPath = $ShortcutTarget
    if($IconLocation) {
        $Shortcut.IconLocation = $IconLocation
    }
    $Shortcut.Save()
}