title: PowerShell - Zip specific files in a folder
body: <p>I know a lot has been written (and asked) about zipping files with PowerShell but despite all my searches and tests I could not come up with what I need. </p>
  
  <p>As per subject I'm working on a script that check a in directory for files created in a specific time range</p>
  
  <pre><code>   $a= Get-ChildItem - path $logFolder | 
  Where-Object {$_.CreationDate -gt $startDate -and $_.CreationDate -lt $endDate}
  </code></pre>
  
  <p>While I can get the list of files I want/need I cannot find a way to send them to a zip file. </p>
  
  <p>I've tried different appraoches like</p>
  
  <pre><code>$sourceFolder = "C:\folder1"
  $destinationZip = "c:\zipped.zip" 
  [Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" )
  [System.IO.Compression.ZipFile]::CreateFromDirectory($sourceFolder, $destinationZip)
  </code></pre>
  
  <p>But while this works well when zipping a folder it's not what I'm looking for, sure enough I could move files to a temporary folder and zip that but looks like a waste and I'm sure there are better ways of doing this. </p>
  
  <p>Keep in mind I cannot use use third party tools like 7zip etc., I cannot use PowerShell extensions nor PowerShell 5 (which would make my life all so easier). </p>
  
  <p>I'm pretty sure answer is rather easy and in plain sight but my brain is in a loop and I cannot figure out how to proceed so any help would be much appreciated. </p>