PowerShell DSC Resource to create shortcut file.
You can install Resource through PowerShell Gallery.
Install-Module -Name DSCR_Shortcut
- cShortcut PowerShell DSC Resource to create shortcut file.
-
[string] Ensure (Write):
- Specify whether or not a shortcut file exists
- The default value is
Present
. { Present | Absent }
-
[string] Path (Key):
- The path of the shortcut file.
- If the path ends with something other than
.lnk
, The extension will be added automatically to the end of the path
-
[string] Target (Required):
- The target path of the shortcut.
-
[string] Arguments (Write):
- The arguments of the shortcut.
-
[string] WorkingDirectory (Write):
- The working directory of the shortcut.
-
[string] WindowStyle (Write):
- You can select window style. { normal | maximized | minimized }
- The default value is
normal
-
[string] Description (Write):
- The description of the shortcut.
-
[string] Icon (Write):
- The path of the icon resource.
-
[string] HotKey (Write):
- HotKey (Shortcut Key) of the shortcut
- HotKey works only for shortcuts on the desktop or in the Start menu.
- The syntax is:
"{KeyModifier} + {KeyName}"
( e.g."Alt+Ctrl+Q"
,"Shift+F9"
) - If the hotkey not working after configuration, try to reboot.
- Example 1: Create a shortcut to the Internet Explore InPrivate mode to the Administrator's desktop
Configuration Example1
{
Import-DscResource -ModuleName DSCR_Shortcut
cShortcut IE_Desktop
{
Path = 'C:\Users\Administrator\Desktop\PrivateIE.lnk'
Target = "C:\Program Files\Internet Explorer\iexplore.exe"
Arguments = '-private'
}
}
- Example 2: WindowStyle, WorkingDirectory, Description, Icon, Hotkey
Configuration Example2
{
Import-DscResource -ModuleName DSCR_Shortcut
cShortcut IE_Desktop
{
Path = 'C:\Users\Administrator\Desktop\PrivateIE.lnk'
Target = "C:\Program Files\Internet Explorer\iexplore.exe"
Arguments = '-private'
WindowStyle = 'maximized'
WorkingDirectory = 'C:\work'
Description = 'This is a shortcut to the IE'
Icon = 'shell32.dll,277'
HotKey = 'Ctrl+Shift+U'
}
}
- Changed not to test for properties not explicitly specified.
- Fix PSSA issues.
- Remove unnecessary files in the published data.
- Fixed issue that the Test-TargetResource always fails when the Target contains environment variables. #9
- Fixed issue that the Test-TargetResource may fails when the Icon is specified.
- Fixed issue that the Test-TargetResource always fails when the HotKey is not specified. #8
- Improved verbose messages.
- Change type of
HotKey
to[string]
- Add
Description
property #1 - Add
HotKey
property #2 - Add
Icon
property #3