Private/Test-CreateShortcut.ps1

function Test-CreateShortcut {
    param (
        [string]$StartMenuProgramsPath,
        [string]$LogPath
    )

    # Ensure the directory exists before creating a shortcut
    if (-Not (Test-Path -Path $StartMenuProgramsPath)) {
        New-Item -ItemType Directory -Path $StartMenuProgramsPath -Force
        Write-Log -Message "Created directory: $StartMenuProgramsPath" -LogPath $LogPath
    }

    # Create Windows PowerShell shortcut
    $powershellShortcutPath = Join-Path -Path $StartMenuProgramsPath -ChildPath "Windows PowerShell.lnk"
    if (-Not (Test-Path -Path $powershellShortcutPath)) {
        $WshShell = New-Object -ComObject WScript.Shell
        $Shortcut = $WshShell.CreateShortcut($powershellShortcutPath)
        $Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
        $Shortcut.Save()
        Write-Log -Message "Created Windows PowerShell shortcut at $powershellShortcutPath." -LogPath $LogPath
    } else {
        Write-Log -Message "Windows PowerShell shortcut already exists at $powershellShortcutPath." -LogPath $LogPath
    }

    # Create File Explorer shortcut
    $parent = Split-Path -Path $StartMenuProgramsPath -Parent
    $explorerShortcutPath = Join-Path -Path $parent -ChildPath "File Explorer.lnk"
    if (-Not (Test-Path -Path $explorerShortcutPath)) {
        $Shortcut = $WshShell.CreateShortcut($explorerShortcutPath)
        $Shortcut.TargetPath = "C:\Windows\explorer.exe"
        $Shortcut.Save()
        Write-Log -Message "Created File Explorer shortcut at $explorerShortcutPath." -LogPath $LogPath
    } else {
        Write-Log -Message "File Explorer shortcut already exists at $explorerShortcutPath." -LogPath $LogPath
    }
}