title: powershell script - create zip file excluding some files and folders
body: <p>I am trying to create powershell script function to zip a folder excluding some folders and files here is my code, which create zip file including all files and folder </p>
  
  <pre><code># Zip creator method
  
  function create-zip([String] $aDirectory, [String] $aZipfile){
      [string]$pathToZipExe = "C:\Program Files\7-zip\7z.exe";
      [Array]$arguments = "a", "-tzip", "$aZipfile", "$aDirectory";
      &amp; $pathToZipExe $arguments;
  }
  </code></pre>
  
  <p>but i want to exclude *.tmp files and bin and obj folder</p>
  
  <p>I found <code>Get-ChildItem "C:\path\to\folder to zip" -Recurse -Exclude *.txt, *.pdf | %{7za.exe a -mx3 "C:\path\to\newZip.zip" $_.FullName}</code> is working fine as powershell command but how to use it in function of script file</p>
  
  <p>Plz suggest...</p>