title: Powershell 7zip (7za) Exclude File types
body: <p>How can I use powershell and 7zip ( 7za.exe ) to ZIP a folder while excluding certain file types?</p>
  
  <p>I tried this:</p>
  
  <pre><code>cd "C:\path\to\folder to zip"
  7za.exe a "C:\path\to\newZip.zip" -mx3 -x!*.txt -x!*.pdf
  </code></pre>
  
  <p>But that returns:</p>
  
  <pre><code>.txt:  WARNING: The system cannot find the file specified.
  
  .pdf:  WARNING: The system cannot find the file specified.
  </code></pre>
  
  <p>and doesn't ZIP anything- just creates an empty ZIP file.</p>
  
  <p>I have also tried this:</p>
  
  <pre><code>cd "C:\path\to\folder to zip"
  Get-ChildItem "C:\path\to\folder to zip" -Recurse -Exclude *.txt, *.pdf | 7za.exe a -mx3 "C:\path\to\newZip.zip" $_.FullName
  </code></pre>
  
  <p>But that ZIPs everything in the "C:\path\to\folder to zip" folder instead of excluding anything..</p>
  
  <p>Thank you for any help you can provide.</p>
  
  <p>-Jim</p>