I'm looking for a way to read the contents of several large zips without going through the trouble of extracting it. The goal is to create a directory list includes File Date Created to check for files created after a certain date.
I'm not sure if powershell is the best tool or this or if it is possible to do this? If not, can someone point me in the right direction?
CodePudding user response:
You can do something very close to this with the .Net System.IO.Compression.FileSystem library. It will allow you to open the zip file and list the contents without having to extract it, but it doesn't include the Creation Date, just the LastWriteTime Date. Probably just as functional for you.
Add-Type -assembly "system.io.compression.filesystem"
$ZipFile = [io.compression.zipfile]::OpenRead("C:\Path\To\ZipFile.zip")
$ZipFile.Entries | Select @{l='ZipFile';e={"C:\Path\To\ZipFile.zip"}},* -Exclude Archive | Export-Csv C:\Path\To\ZipFile.csv -NoTypeInfo
That probably dumps a little more info than you want, but having more info is not usually a bad thing.
CodePudding user response:
I found a script here that is beautiful and almost works.
https://techibee.com/powershell/reading-zip-file-contents-without-extraction-using-powershell/2152
The only thing it doesn't do is give me Creation Date or Date Last Mod.
I tried to add those member types, but I perhaps did not do it correctly.
$Object | Add-member -MemberType Noteproperty -Name CreateDate -Value $CreateDate
$Object | Add-member -MemberType Noteproperty -Name DateLastModified -Value $DateLastModified