title: Powershell - Delete Files/Folder with Config File
body: <p>i already have a Powershell Script, that runs through a specified Folder and deletes all the Content out of it. Now we saw, that we need to keep some of the Subfolders and Files.</p>
  
  <p>Lets say there is a folder named "Stuff" with 2 Subfolders called "Important" and "NotImportant". Both of the Subfolders have Data in it. Also the Folder "Stuff" has some files in it. </p>
  
  <p>Because my Script is used to work with a lots of different Folders, we would need to use a "Config-File", in which a Person defines what Folders and Files should be kept. For Example the file has the path "directory\Stuff\Important" in it, then the script ignores it. Also if there is "directory\Stuff\examplefile.doc" in it, the file will be ignored during the deletion process.</p>
  
  <p>Can someone help me with this?</p>
  
  <p><em>Update</em></p>
  
  <p>Currently my Script looks like this. Its a simple Update Script for a WebserverFarm</p>
  
  <pre><code>[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
  $Pfad = [Microsoft.VisualBasic.Interaction]::InputBox("Bitte den Websitenamen angeben", "Website angeben") 
  
  if ($Pfad -eq "")
  {
   [System.Windows.Forms.MessageBox]::Show("Vorgang abgebrochen" , "Error")
  }  
  else
  {
      if(Test-Path -Path Directory\Content\$pfad\)
      {  
  
      Add-Type -Assembly "System.IO.Compression.FileSystem";[System.IO.Compression.ZipFile]::CreateFromDirectory("Directory\Content\$pfad", "Directory\Content_Backup\$pfad-$(Get-Date -Format dd-MM-yyyy_HH-mm-ss).zip");
  
      Copy-Item -Path "Directory\WebSite_Update\app_offline.htm" -Destination "Directory\Content\$pfad\"
      start-sleep -s 10
  
      Remove-Item -Path Directory\Content\$pfad\* -Recurse -Exclude app_offline*
      Copy-Item -Path Directory\WebSite_Update\$pfad\* -Destination Directory\Content\$pfad\ -Recurse 
  
      Remove-Item Directory\Content\$pfad\app_offline.htm
  
  
      [System.Windows.Forms.MessageBox]::Show("Website Update beendet. Bitte die Webseite überprüfen" , "Status")
  
      }
  
      else
      {
      [System.Windows.Forms.MessageBox]::Show("Bitte eine gültige Eingabe machen!" , "Error")
      }
  
  }
  </code></pre>
  
  <p>else
   {
   [System.Windows.Forms.MessageBox]::Show("Bitte das Script als Administrator ausführen!" , "Error")
   }</p>