22 lines
598 B
PowerShell
22 lines
598 B
PowerShell
# Remove All Shortcuts from Public Desktop Folder
|
|
|
|
# Set the path to the Public Desktop folder
|
|
$publicDesktop = "$env:Public\Desktop"
|
|
|
|
# Counter for deleted shortcuts
|
|
$deletedCount = 0
|
|
|
|
# Check if the Public Desktop folder exists
|
|
if (!(Test-Path $publicDesktop)) {
|
|
Write-Warning "Error: Public Desktop folder not found."
|
|
exit 1
|
|
}
|
|
|
|
# Remove all .lnk files from the Public Desktop
|
|
Get-ChildItem $publicDesktop -Filter "*.lnk" | ForEach-Object {
|
|
Remove-Item $_.FullName -Force
|
|
$deletedCount++
|
|
}
|
|
|
|
# Display results
|
|
Write-Host "Deleted $deletedCount shortcut(s) from the Public Desktop." |