Create App Shortcut in Startmenu
Detection Script
$startMenuShortcut = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Application XYZ.lnk"
if (Test-Path $startMenuShortcut) {
Write-Output "Startmenu shortcut exist"
exit 0
} else {
Write-Output "Startmenu shortcut missing"
exit 1
}Remediation Script
$startMenuShortcut = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Application XYZ.lnk"
$path = "PathToExe"
if (-not (Test-Path $startMenuShortcut)) {
Write-Output "Creating Startmenu shortcut..."
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($startMenuShortcut)
$Shortcut.TargetPath = $path
$Shortcut.Arguments = ""
$Shortcut.IconLocation = "$path, 0"
$Shortcut.WorkingDirectory = Split-Path $path
$Shortcut.Save()
}Create Edge InPrivat Shortcut on Desktop and Startmenu
Detection Script
$desktopShortcut = "C:\Users\Public\Desktop\Microsoft Edge InPrivate.lnk"
$startMenuShortcut = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge InPrivate.lnk"
$desktopExists = Test-Path $desktopShortcut
$startMenuExists = Test-Path $startMenuShortcut
if ($desktopExists -and $startMenuExists) {
Write-Output "Both shortcuts exist"
exit 0
} else {
if (-not $desktopExists) { Write-Output "Desktop shortcut missing" }
if (-not $startMenuExists) { Write-Output "Start menu shortcut missing" }
exit 1
}Remediation Script
$desktopShortcut = "C:\Users\Public\Desktop\Microsoft Edge InPrivate.lnk"
$startMenuShortcut = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge InPrivate.lnk"
$edgePath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
$targetUrl = "URL"
if (-not (Test-Path $desktopShortcut)) {
Write-Output "Creating desktop shortcut..."
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($desktopShortcut)
$Shortcut.TargetPath = $edgePath
$Shortcut.Arguments = "--inprivate $targetUrl"
$Shortcut.IconLocation = "$edgePath, 0"
$Shortcut.WorkingDirectory = Split-Path $edgePath
$Shortcut.Save()
}
if (-not (Test-Path $startMenuShortcut)) {
Write-Output "Creating start menu shortcut..."
Copy-Item -Path $desktopShortcut -Destination $startMenuShortcut -Force
}