Skip to content

Instantly share code, notes, and snippets.

@stef-k
Created December 24, 2020 18:08
Show Gist options
  • Save stef-k/2c8e515fe8c8d12c6317ca786c8c7915 to your computer and use it in GitHub Desktop.
Save stef-k/2c8e515fe8c8d12c6317ca786c8c7915 to your computer and use it in GitHub Desktop.

Revisions

  1. stef-k created this gist Dec 24, 2020.
    6 changes: 6 additions & 0 deletions delete-files-and-folders-in-user-desktop.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # Removes all files and folders in user's Desktop except shortcuts
    # Warning !!!
    # Remove the -WhatIf to actually delete the file and directory objects !!!
    #
    Remove-Item "$home\Desktop\*" -Recurse -Exclude "*.lnk" -WhatIf
    Remove-Item "$home\Desktop\*.*" -Recurse -Exclude "*.lnk" -WhatIf