Harihara Vinayakaram
Harihara Vinayakaram

Reputation: 169

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 ?

Upvotes: 1

Views: 44

Answers (1)

Piotr Stapp
Piotr Stapp

Reputation: 19830

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"

Upvotes: 1

Related Questions