# Remove-item -exclude .exe?

**URL:** https://forums.powershell.org/t/remove-item-exclude-exe/3645
**Category:** PowerShell Help
**Created:** [January 20, 2015, 7:21am UTC](https://forums.powershell.org/t/remove-item-exclude-exe/3645 "2015-01-20T07:21:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![danny-brooks](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@danny-brooks](https://forums.powershell.org/u/danny-brooks)
#### Post date: [January 20, 2015, 7:21am UTC](https://forums.powershell.org/t/remove-item-exclude-exe/3645/1 "2015-01-20T07:21:00Z")

</div>

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[
```

---

<div class="post-metadata">

### Author: ![danny-brooks](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@danny-brooks](https://forums.powershell.org/u/danny-brooks)
#### Post date: [January 20, 2015, 7:33am UTC](https://forums.powershell.org/t/remove-item-exclude-exe/3645/2 "2015-01-20T07:33:13Z")

</div>

Nevermind, I could just use _exe_.

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 8:46pm UTC](https://forums.powershell.org/t/remove-item-exclude-exe/3645/3 "2024-05-16T20:46:29Z")

</div>


