Remove-item -exclude .exe?

Welcome Forums General PowerShell Q&A Remove-item -exclude .exe?

This topic contains 1 reply, has 1 voice, and was last updated by

 
Participant
3 years, 11 months ago.

  • Author
    Posts
  • #22016

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    Nevermind, I could just use *exe*.

The topic ‘Remove-item -exclude .exe?’ is closed to new replies.