Forum Discussion
AB21805
Mar 14, 2022Bronze Contributor
deleting a shortcut on desktop via intune
Hi all, How do I delete a shortcut via intune? I have created a shortcut using powershell but I had to update the URL which seems to have broke the shortcut so need to delete it and redeploy...
- Mar 15, 2022
AB21805 Changed it to handle both situations:
Detection:
$desktop = [Environment]::GetFolderPath("Desktop") if (Test-Path -Path "$($desktop)\Wifi Connect.lnk") { write-Host Found shortcut exit 1 } Else { Write-Host Shortcut not found exit 0 }
Remediation:
$desktop = [Environment]::GetFolderPath("Desktop") Remove-Item -Path "$($desktop)\Wifi Connect.lnk" -Force:$true
AB21805
Mar 15, 2022Bronze Contributor
some students have got this set up too.
I would think I need to put both in the script, is that possible
I would think I need to put both in the script, is that possible
Mar 15, 2022
AB21805 Changed it to handle both situations:
Detection:
$desktop = [Environment]::GetFolderPath("Desktop")
if (Test-Path -Path "$($desktop)\Wifi Connect.lnk") {
write-Host Found shortcut
exit 1
}
Else {
Write-Host Shortcut not found
exit 0
}
Remediation:
$desktop = [Environment]::GetFolderPath("Desktop")
Remove-Item -Path "$($desktop)\Wifi Connect.lnk" -Force:$true
- Mar 15, 2022It should clear up the next time, it gives you the status 'with issues' because it detected a condition that you don't want (Shortcut exists) Remediation worked, issue fixed, and it should report 'Without issues' later on
- AB21805Mar 15, 2022Bronze Contributor
I am now confused aha
Issue fixed on remediation status but with issues on detection status