Powershell3.0_4.0解压zip


当你安装了.Net4.5及以后版本,你可以这样尝试解压缩:

#requires -Version 2
# .NET Framework 4.5 required!

Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction Stop

$Source = 'C:\somezipfile.zip'
$Destination = 'C:\somefolder'
$Overwrite = $true
$ShowDestinationFolder = $true

if ((Test-Path $Destination) -eq $false) 
{
 $null = mkdir $Destination 
}

$Content = [IO.Compression.ZipFile]::OpenRead($Source).Entries
$Content | 
 ForEach-Object -Process {
    $FilePath = Join-Path -Path $Destination -ChildPath $_
                [IO.Compression.ZipFileExtensions]::ExtractToFile($_,$FilePath,$Overwrite)
            }
if ($ShowDestinationFolder) 
{
 explorer.exe $Destination 
}

Unzipping ZIP Files with PowerShell 3.0 and 4.0

×用微信扫描并分享
本文链接: https://www.pstips.net/unzipping-zip-files-with-powershell-3-0-and-4-0.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注