My first attempt to create a DSC resource.
- Create a directory cShortcut in "C:\Program Files\WindowsPowerShell\Modules"
- Copy the files to this directory
Start Powershell and paste the following:
Configuration DesktopShortcut {
Import-DscResource -ModuleName cShortcut
Node "localhost" {
Shortcut Logoff
{
Ensure = "Present"
ShortCutName = "C:\Users\Public\Desktop\Logoff.lnk"
Executable = "C:\Windows\System32\Logoff.exe"
Description = "Logoff from Windows"
IconLocation = "%SystemRoot%\system32\SHELL32.dll,44"
}
}
}
DesktopShortcut
This will create a folder 'DesktopShortcut' in the current directory.
Next, use this command to start the actual configuration:
Start-DscConfiguration -Path .\DesktopShortcut\ -Wait -Verbose
Adding -Wait
and -Verbose
will make the config run immediatly and shows the output to determine if it worked.
It will create a logoff shortcut on your desktop.