Use Expand-Archive to expand ZIP if available (#423)

This commit is contained in:
Max Y 2019-03-01 13:01:43 -08:00 коммит произвёл vikasnav
Родитель f0a5afb5f1
Коммит d9bda326a8
1 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -42,12 +42,20 @@ function DownloadFile($uri)
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
if (Get-Command Expand-Archive -ErrorAction SilentlyContinue)
{
# 16 - Respond with "Yes to All" for any dialog box that is displayed.
$shell.Namespace($destination).copyhere($item, 16)
Expand-Archive -Path $file -DestinationPath $destination
}
else
{
# Fall back to COM to expand the zip
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
# 16 - Respond with "Yes to All" for any dialog box that is displayed.
$shell.Namespace($destination).copyhere($item, 16)
}
}
}