简体   繁体   中英

PowerShell zip file extraction catching exceptons

I am having the following code in Power Shell ( windows Server 2016 TP3 )

$zipFrom = Get-Item($zipfilepath);
$destTo=Get-Item($destination)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfrom,$destTo)

The problem is that I get the dreaded 260 character file limit error . The question is how do i ignore error and continue with the extraction ?

Unfortunate it is not possible. Instead of you can use free 7-zip which can handle above problem.

The code could be:

set-alias 7zip "C:\Program Files\7-Zip\7z.exe"

$zipFrom = Get-Item($zipfilepath);
$destTo=Get-Item($destination)
7zip x $zipfrom -o"$destTo"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM