Remove-item -exclude .exe?

This topic contains 1 reply, has 1 voice, and was last updated by  Danny Brooks 3 years, 4 months ago.

  • Author
  • #22016

    Danny Brooks

    I have this short script that reads a list of computers and deletes the contents of the Desktop and Documents folder. I have it excluding 1 file, but it doesn't seem to work for .exe (programs) – unless I've been inputting it wrong.

    $computers = Get-Content C:\users\*\desktop\computers.txt
          invoke-command -computername $computers {remove-item -Path "C:\users\*\documents\*", "C:\users\*\desktop\*" -recurse -Exclude Survey2015.pdf} | Out-Null[
  • #22019

    Danny Brooks

    Nevermind, I could just use *exe*.

You must be logged in to reply to this topic.