Forum Discussion
Intune installed desktop shortcut needs to be removed
- Jan 11, 2024The detection is OK if you want the shortcut removed. You must assign a group to Uninstall the program, and it will run the uninstall script. The detection will check again to see if the file is still there. If not, The removal of the shortcut should be complete.
What does your uninstall command line look like? It should be powershell.exe -Executionpolicy Bypass -File .\uninstall.ps1
Jesse13579 When you add an Intunewin app to Intune, you can select the Installation behavior to be System or User.
- Jesse13579Jan 10, 2024Brass Contributor
Harm_Veenstra I just checked and I do have the instillation behavior set to System. I went through and verified a few of the machines and the desktop shortcut is still there even though the app says it ran correctly.
- Jan 10, 2024$ShortcutFile = "$env:Public\Desktop\UKG.lnk"
if (Test-Path $ShortcutFile){ Remove-Item $ShortcutFile -Force:True -Confirm:$False}
else { Write-Output "Shortcut Not Found" }
Does that work? Test it on your machine first in a powershell prompt- Jesse13579Jan 11, 2024Brass Contributor
Harm_Veenstra when I run that script in an elevated powershell or a regular powershell I get
PS C:\ukg2> .\uninstall.ps1
Remove-Item : Cannot convert 'System.String' to the type 'System.Management.Automation.SwitchParameter' required by
parameter 'Force'.
At C:\ukg2\uninstall.ps1:3 char:64
+ ... st-Path $ShortcutFile){ Remove-Item $ShortcutFile -Force:True -Confir ...
+ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.RemoveItemCommandWhen I run the original script
$ShortcutFile = "$env:Public\Desktop\UKG.lnk"
if (Test-Path $ShortcutFile){ Remove-Item $ShortcutFile }
else { Write-Output "Shortcut Not Found" }
I get this error in a standard powershell window.
Remove-Item : Cannot remove item C:\Users\Public\Desktop\UKG.lnk: Access to the path 'C:\Users\Public\Desktop\UKG.lnk'
is denied.
At C:\ukg2\uninstall2.ps1:3 char:31
+ if (Test-Path $ShortcutFile){ Remove-Item $ShortcutFile }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\Users\Public\Desktop\UKG.lnk:FileInfo) [Remove-Item], Unauthorized
AccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand