title: Powershell ZIP CopyHere counteracting asynchronous behavior
body: <p>Within Powershell, the CopyHere method for the Shell-Application Namespace is asynchronous.  My main goal with this is to convert a KML file to a KMZ file.  The process of doing this is to create a ZIP file with the same name, copy the KML into the KMZ (compresses the file) and then rename the ZIP to KMZ.  Unfortunately, being asynchronous means the rename function is being called before the CopyHere method is completed.  I have found many examples of solving this.  The cleanest one I found is below:</p>
  
  <pre><code>$kmlPath = $global:directoryPath + "Test.kml"
  $zip = $global:directoryPath + "Test.zip"
  New-Item $zip -ItemType file
  $shellApplication = new-object -com shell.application
  $zipPackage = $shellApplication.NameSpace($zip)
  $zipPackage.CopyHere($kmlPath, 16)
  
  while($zipPackage.Items().Item($zip.Name) -Eq $null)
  {
      start-sleep -seconds 1
      write-host "." -nonewline
  }
  write-host "."
  Rename-Item -Path $zip -NewName $([System.IO.Path]::ChangeExtension($zip, ".kmz"))
  </code></pre>
  
  <p>This responds with the following error:</p>
  
  <blockquote>
    <p>Exception calling "Item" with "1" argument(s): "Not implemented
    (Exception from HRESULT: 0x80004001 (E_NOTIMPL))"
    + while($zipPackage.Items().Item($zip.Name) -Eq $null)
    +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ComMethodTargetInvocation</p>
  </blockquote>
  
  <p>Am I misusing the Item method for this particular package?  I am confused why something that "appears" to be neatly done is not working.  I have also tried the snippet of code provided <a href="https://stackoverflow.com/questions/22027897/zipping-a-large-folder-fails">Here</a>.  It also complains about the .Item method in this particular situation.</p>