windows 10 1709+/win11 自带 powershell 的 expand-archive 和 compress-archive 命令可直接解压/压缩 zip 文件,支持路径含空格中文、强制覆盖、批量处理及压缩等级设置,无需第三方工具。
windows 自带 powershell 就能直接解压和压缩 zip 文件,不需要装任何第三方软件。只要系统是 windows 10 1709 或更新版本(包括 win11),powershell 5.0+ 都已预装 expand-archive 和 compress-archive 这两个命令,操作简单、稳定可靠。
用 Expand-Archive 解压 ZIP 文件
这是最常用、最直接的解压方式,支持单个或批量处理,自动建目录、可覆盖同名文件。
- 解压到当前目录:在 PowerShell 中运行
Expand-Archive -Path "C:\data\archive.zip" -DestinationPath "." - 解压到指定文件夹(路径不存在会自动创建):
Expand-Archive -Path "D:\backup.zip" -DestinationPath "E:\restored" - 强制覆盖已有文件加
-Force参数:Expand-Archive -Path "file.zip" -DestinationPath "out" -Force - 路径含空格或中文时,必须用英文双引号包裹,例如:
Expand-Archive -Path "C:\我的备份\2026.zip" -DestinationPath "C:\提取结果"
用 Compress-Archive 压缩成 ZIP 文件
可以打包单个或多个文件/文件夹,支持压缩等级控制,适合日常归档或自动化脚本。
- 压缩一个文件夹:
Compress-Archive -Path "C:\Project" -DestinationPath "C:\backup\project.zip" - 同时压缩多个项目:
Compress-Archive -Path "A.txt", "B.docx", "Data" -DestinationPath "bundle.zip" - 设置压缩级别(Optimal 最小体积,Fastest 最快,NoCompression 不压缩):
-CompressionLevel Optimal - 覆盖已有 ZIP 文件需加
-Force,例如:Compress-Archive -Path "new.log" -DestinationPath "logs.zip" -Force
批量解压当前目录所有 ZIP 文件
适合下载了一堆压缩包后快速释放内容,每个 ZIP 会解到独立子文件夹里,互不干扰。
- 先进入目标文件夹:
cd "C:\Downloads\zips" - 运行批量命令:
Get-ChildItem -Filter *.zip | ForEach-Object { $dest = Join-Path "C:\output" $_.BaseName; Expand-Archive -Path $_.FullName -DestinationPath $dest -Force } - 执行后,
C:\output下会出现file1、file2等同名子文件夹,各自存放对应 ZIP 的内容
注意事项和常见问题
有些情况容易出错,提前注意能省去不少排查时间。
- 如果提示
Expand-Archive : The term 'Expand-Archive' is not recognized,说明 PowerShell 版本太低(低于 5.0),可升级系统或改用tar -xzf(Win10 1803+ 支持) -
tar命令也能解压 ZIP:tar -xf archive.zip -C .,但对中文路径兼容性不如 Expand-Archive - 避免用中文或特殊字符命名 ZIP 文件本身——虽然能解,但某些脚本中可能因编码问题失败
- 想保留原始 ZIP 的时间戳和目录结构?Expand-Archive 默认就支持,无需额外参数











