Extract Specific Files from ZIP Archive in an ZIP Archive

My Ex. Archive:

– file_3.txt
– file_1.txt
– file_2.txt


$Path = “$Home\Desktop\Archive.zip”
$Filter = ‘second.zip’
$OutPath = ‘C:\Tmp’
$exists = Test-Path -Path $OutPath
if ($exists -eq $false)
$null = New-Item -Path $OutPath -ItemType Directory -Force
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [System.IO.Compression.ZipFile]::OpenRead($Path)
$zip.Entries |
Where-Object { $.FullName -like $Filter } |
ForEach-Object {
$FileName = $
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, “$OutPath$FileName”, $true)

I would like to extract the file "file_3.txt" directly from the second zip archive
without extract the second archive before

Not sure that you can extract a file that is compressed in another file without opening the parent file. That’s like unbuttoning your shirt with your jacket zipped up. Assuming you are getting the core code from here:

As you can see in that example and in your code above, those are zip entries, not the actual files. In order to access the .ZIP file, it appears it has to be extracted first. Once you open Archive.zip, extract Second.zip, open Second.zip and extract file3, you can remove second.zip from the extracted path to cleanup.