我有超过 1000 个 .zip 文件,我需要通过这些文件来查找 .pst 文件。这些 .zip 文件由 VMware Horizon 的组件使用,因此无法先解压缩它们。
我试过使用 dir 甚至 dir -force,但这些不会自动深入到 zip 文件的内容中。
powershell 或 Windows 命令提示符中是否有内置方法可以打印 .zip 文件的内容,而无需我先解压缩文件夹?
最佳答案
使用 .Net 框架中的 ZipFile 类。要列出存档文件中的条目,您可以在 Powershell 中像这样使用它:
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
{
[IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries.FullName |
%{ "$sourcefile`:$_" }
}
或者,如果你有 PowerShell 社区扩展,你可以使用它的
Read-Archive
小命令。https://archive.codeplex.com/?p=pscx
关于powershell - 如何在 Powershell 中列出 .zip 文件的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57117870/