New-Shortcut
SYNOPSIS
Creates a new .lnk or .url type shortcut
SYNTAX
New-Shortcut [-Path] <String> -TargetPath <String> [-Arguments <String>] [-IconLocation <String>]
[-IconIndex <Int32>] [-Description <String>] [-WorkingDirectory <String>] [-WindowStyle <String>]
[-RunAsAdmin] [-Hotkey <String>] [-ContinueOnError <Boolean>] [<CommonParameters>]
DESCRIPTION
Creates a new shortcut .lnk or .url file, with configurable options
EXAMPLES
EXAMPLE 1
New-Shortcut -Path "$envProgramData\Microsoft\Windows\Start Menu\My Shortcut.lnk" -TargetPath "$envWinDir\System32\notepad.exe" -IconLocation "$envWinDir\System32\notepad.exe" -Description 'Notepad' -WorkingDirectory "$envHomeDrive\$envHomePath"
PARAMETERS
-Path
Path to save the shortcut
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-TargetPath
Target path or URL that the shortcut launches
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Arguments
Arguments to be passed to the target path
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-IconLocation
Location of the icon used for the shortcut
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-IconIndex
The index of the icon. Executables, DLLs, ICO files with multiple icons need the icon index to be specified. This parameter is an Integer. The first index is 0.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Description
Description of the shortcut
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-WorkingDirectory
Working Directory to be used for the target path
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-WindowStyle
Windows style of the application. Options: Normal, Maximized, Minimized. Default is: Normal.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-RunAsAdmin
Set shortcut to run program as administrator. This option will prompt user to elevate when executing shortcut.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Hotkey
Create a Hotkey to launch the shortcut, e.g. "CTRL+SHIFT+F"
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ContinueOnError
Continue if an error is encountered. Default is: $true.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
None
You cannot pipe objects to this function.
OUTPUTS
None. This function does not return any output.
NOTES
Url shortcuts only support TargetPath, IconLocation and IconIndex. Other parameters are ignored.