Powershell Scripting Games - Day 6

This is my solution for Beginner Event 6

Here we got a script that was not working and had to debug it.

#==========================================================================
# NAME: Beg_6.ps1
#
# COMMENT: Key concepts are listed below:
#1. Uses wscript.shell to create three shortcuts on the desktop. The first is a shortcut
#2. to this actual script. It uses the scriptfullName property to assign the path.
#3. The second is a simple Web site URL shortcut. The third one is a shortcut to
#4. Notepad.
#==========================================================================
  
$ErrorActionPreference = "SilentlyContinue"
Set-PSDebug -Strict
  
#initialize all the variables
New-Variable -Name objShell #instance of the wshSHell object
New-Variable -Name strDesktop #pointer to desktop special folder
New-Variable -Name objShortCut #used to set properties of the shortcut. 
#Comes from using createShortCut
New-Variable -Name objURL #used to set properties of webshortcut.
  
$objShell = New-Object -ComObject ("WScript.Shell")
$strDesktop = $objShell.SpecialFolders.item("Desktop")
  
#Create shortcut to script
$objShortCut = $objShell.CreateShortcut($strDesktop + "\Shortcut Script.lnk")
$objShortCut.TargetPath = $myInvocation.mycommand.path
$objShortCut.WindowStyle = 0
$objShortCut.Hotkey = "CTRL+SHIFT+F"
$objShortCut.IconLocation = "notepad.exe, 2"
$objShortCut.Description = "Shortcut Script"
$objShortCut.WorkingDirectory = $strDesktop
$objShortCut.Save
  
#Create url link
$objURL = $objShell.CreateShortcut($strDesktop + "\The Microsoft Scripting Guys.url")
$objURL.TargetPath = "https://www.ScriptingGuys.com"
$objURL.Save()
  
#Create shotrcut to notepad
$objShortCut = $objShell.CreateShortcut($strDesktop + "\notepad.lnk")
$objShortCut.TargetPath = "notepad.exe"
$objShortCut.IconLocation = "notepad.exe, 0"
$objShortCut.description = "notepad"
$objShortCut.Save()