34

I run the following to unzip and want to overwrite the current files if they exist but the Microsoft solution doesn't seem to work. I haven't found anything that says it works so is there a work around to select the 'yes to all' option?

$zipPackage = (new-object -com shell.application).NameSpace($zipfilename)
$destinationFolder = (new-object -com shell.application).NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items(),16)
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
Bruce227
  • 893
  • 5
  • 14
  • 25

2 Answers2

54

If you want it to overwrite AND be silent change 0x10 to 0x14 (docs).

$destinationFolder.CopyHere($zipPackage.Items(), 0x14) 
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
Peter
  • 9,643
  • 6
  • 61
  • 108
1

My pragmatic remedy for this issue would be to use something like 7-Zip. Which has a nice commandline interface easily used from within PowerShell.

Bas Bossink
  • 9,388
  • 4
  • 41
  • 53