35 lines
1.1 KiB
PowerShell
35 lines
1.1 KiB
PowerShell
# Script to remove Microsoft Edge desktop shortcut if it exists
|
|
# Get the currently logged in username
|
|
$currentUser = [System.Environment]::UserName
|
|
|
|
# Define the path to the current user's desktop
|
|
$desktopPath = "C:\Users\$currentUser\Desktop"
|
|
|
|
# Define the possible Edge shortcut names
|
|
$edgeShortcuts = @(
|
|
"Microsoft Edge.lnk",
|
|
"Microsoft Edge (Beta).lnk",
|
|
"Microsoft Edge (Dev).lnk",
|
|
"Microsoft Edge (Canary).lnk"
|
|
)
|
|
|
|
# Loop through potential shortcut names
|
|
foreach ($shortcut in $edgeShortcuts) {
|
|
$fullPath = Join-Path -Path $desktopPath -ChildPath $shortcut
|
|
|
|
# Check if the shortcut exists
|
|
if (Test-Path $fullPath) {
|
|
try {
|
|
# Remove the shortcut
|
|
Remove-Item $fullPath -Force
|
|
Write-Host "Deleted shortcut: $shortcut from $currentUser's desktop"
|
|
}
|
|
catch {
|
|
Write-Host "Error deleting shortcut $shortcut : $_"
|
|
}
|
|
}
|
|
else {
|
|
Write-Host "Shortcut $shortcut not found on $currentUser's desktop"
|
|
}
|
|
}
|
|
Write-Host "Edge shortcut removal process completed for user $currentUser." |