use remove-item for both the shortcut and the file.
PS H:\> gci $ENV:USERPROFILE\desktop
Directory: C:\Users\\desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 8/24/2015 8:31 AM 1122 service request form SC.lnk
-a--- 8/24/2015 8:30 AM 11249 service request form.docx
-a--- 3/9/2015 7:51 AM 5729 ts.exe - Shortcut.lnk
PS H:\> Remove-Item $ENV:USERPROFILE\Desktop\'Service Request Form.docx'
PS H:\> gci $ENV:USERPROFILE\desktop
Directory: C:\Users\\desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 8/24/2015 8:31 AM 1122 service request form SC.lnk
-a--- 3/9/2015 7:51 AM 5729 ts.exe - Shortcut.lnk
PS H:\> Remove-Item $ENV:USERPROFILE\Desktop\'Service Request Form sc.lnk'
PS H:\> gci $ENV:USERPROFILE\desktop
Directory: C:\Users\\desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 3/9/2015 7:51 AM 5729 ts.exe - Shortcut.lnk
Also I had no issue moving a shortcut to my recycle bin after the file had been deleted. Can you post the error message?
Removing Desktop Icons
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.