title: Delete all files and folders but exclude a subfolder
body: <p>I have a folder where I need to delete all files and folders except a small list of files and folders.</p>
  
  <p>I can already exclude a list of files, but don't see a way to exclude a folder and its contents.</p>
  
  <p>Here is the folder structure:</p>
  
  <pre><code>|-C:\temp
   \-C:\temp\somefile.txt
   \-C:\temp\someotherfile.txt
  | |-C:\temp\foldertodelete
     \-C:\temp\foldertodelete\file1.txt
  | |-C:\temp\foldertokeep
  |  \-C:\temp\foldertokeep\file2.txt
  </code></pre>
  
  <p>I want to keep somefile.txt and the folder foldertokeep and its content.</p>
  
  <p>This is what I have right now:</p>
  
  <pre><code>Get-ChildItem -Path  'C:\temp' -Recurse -exclude somefile.txt | Remove-Item -force -recurse
  </code></pre>
  
  <p>This really does not delete somefile.txt. Is there a way to exclude folder foldertokeep and its content from the delete list?</p>