This is my solution for Beginner Event 6
Here we got a script that was not working and had to debug it.
1: #==========================================================================
2: #
3: # NAME: Beg_6.ps1
4: #
5: # COMMENT: Key concepts are listed below:
6: #1. Uses wscript.shell to create three shortcuts on the desktop. The first is a shortcut
7: #2. to this actual script. It uses the scriptfullName property to assign the path.
8: #3. The second is a simple Web site URL shortcut. The third one is a shortcut to
9: #4. Notepad.
10: #==========================================================================
11:
12: $ErrorActionPreference = "SilentlyContinue"
13: Set-PSDebug -Strict
14:
15: #initialize all the variables
16: New-Variable -Name objShell #instance of the wshSHell object
17: New-Variable -Name strDesktop #pointer to desktop special folder
18: New-Variable -Name objShortCut #used to set properties of the shortcut.
19: #Comes from using createShortCut
20: New-Variable -Name objURL #used to set properties of webshortcut.
21:
22: $objShell = New-Object -ComObject ("WScript.Shell")
23: $strDesktop = $objShell.SpecialFolders.item("Desktop")
24:
25: #Create shortcut to script
26: $objShortCut = $objShell.CreateShortcut($strDesktop + "\Shortcut Script.lnk")
27: $objShortCut.TargetPath = $myInvocation.mycommand.path
28: $objShortCut.WindowStyle = 0
29: $objShortCut.Hotkey = "CTRL+SHIFT+F"
30: $objShortCut.IconLocation = "notepad.exe, 2"
31: $objShortCut.Description = "Shortcut Script"
32: $objShortCut.WorkingDirectory = $strDesktop
33: $objShortCut.Save
34:
35: #Create url link
36: $objURL = $objShell.CreateShortcut($strDesktop + "\The Microsoft Scripting Guys.url")
37: $objURL.TargetPath = "http://www.ScriptingGuys.com"
38: $objURL.Save()
39:
40: #Create shotrcut to notepad
41: $objShortCut = $objShell.CreateShortcut($strDesktop + "\notepad.lnk")
42: $objShortCut.TargetPath = "notepad.exe"
43: $objShortCut.IconLocation = "notepad.exe, 0"
44: $objShortCut.description = "notepad"
45: $objShortCut.Save()