Hi,
I have a zip file contains folders, sub folders and files.
I want to extract a specific sub folder along with files and folders in it.
Can anyone suggest a way to accomplish this. I tried the below code but no luck.
$xtrctfolder = "Valueadd\Data\Current\admin\production\" $destination = "D:\Dinesh\Final_xtract" Add-Type -Assembly System.IO.Compression.FileSystem $zip = [IO.Compression.ZipFile]::OpenRead($sourcePath) $zip.Entries | where {$_.Name -eq $xtrctfolder} | foreach { $target_path = [System.IO.Path]::Combine($destination, $_.Name) $target_folder = [System.IO.Path]::GetDirectoryName($target_path) if(!(Test-Path $target_folder )) { New-Item -ItemType Directory -Path $target_folder | Out-Null } if(!$target_path.EndsWith("\")) { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $target_path, $true); } }
Thanks
Dinesh