且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

试图从 zip powershell 中仅提取 .sql 文件

更新时间:2023-12-04 21:15:04

如果您拥有(或获取)PowerShell 社区扩展,你可以使用它的归档命令:

If you have (or grab) the PowerShell Community Extensions, you can use its archive commands:

Read-Archive C:\temp\foo.zip | %{$_} | Where Name -match '\.sql' | Expand-Archive

如果您在安装了 .NET 4.5 的系统上使用 PowerShell V3,您可以使用 System.IO.Compression.ZipFile 类来提取 sql 文件.

If you are on PowerShell V3 on a system with .NET 4.5 installed, you can use the System.IO.Compression.ZipFile class to extract the sql files.

Add-Type -Assembly system.io.compression.filesystem
[IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $extractPath)