title: Passing Relative Paths to Powershell shell.application Namespace
body: <p>I'm attempting to get the function from this page:
  <a href="https://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/" rel="nofollow noreferrer">https://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/</a> working using relative parameters. </p>
  
  <p>So I have this function:</p>
  
  <pre><code>function Expand-ZIPFile($file, $destination)
  {
      Write-Host "Unzipping $file to $destination" -ForegroundColor Yellow
      $shell = new-object -com shell.application
      $zip = $shell.NameSpace($file)
      foreach($item in $zip.items())
      {
          $shell.Namespace($destination).copyhere($item)
      }
  }
  </code></pre>
  
  <p>And I attempt to call it like so:</p>
  
  <pre><code>$zipPath = Resolve-Path ".\myZip.zip"
  $destinationPath = Resolve-Path ".\"
  Expand-ZIPFile -File $zipPath -Destination $destinationPath
  </code></pre>
  
  <p>Output wise I see:</p>
  
  <pre><code>Unzipping D:\test\myZip.zip to D:\test
  You cannot call a method on a null-valued expression.
  At D:\test\Unzip.ps1:14 char:22
  +     foreach($item in $zip.items())
  +                      ~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>
  
  <p>Which I'm assuming is because the <code>namespace</code> isn't being interpretted correctly because if I call:</p>
  
  <pre><code>Expand-ZIPFile -File "D:\test\myZip.zip" -Destination "D:\test"
  </code></pre>
  
  <p>This works fine, and I see:</p>
  
  <pre><code>Unzipping D:\test\myZip.zip to D:\test
  </code></pre>
  
  <p>in the console as well. </p>
  
  <p>How can I pass in the 'resolved' strings, as I can't see what's missing here. </p>
  
  <p>I have also tried wrapping the resolved strings in <code>"</code> to see if that made a difference (<code>$zipPath = '"' + $zipPath + '"'</code>) but to no avail.</p>