Remove-item -exclude .exe?

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Danny Brooks Danny Brooks 1 year, 10 months ago.

  • Author
    Posts
  • #22016
    Profile photo of Danny Brooks
    Danny Brooks
    Participant

    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
    Profile photo of Danny Brooks
    Danny Brooks
    Participant

    Nevermind, I could just use *exe*.

You must be logged in to reply to this topic.