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.