Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Compressing and Extracting Files and Folders
Summary
This TechNet Wiki is to demo Compressing and Extracting Files and Folders using PowerShell 5.0
Requirement
- Windows 7 Enterprise SP1
- WMF 5.0
Code
Starting in Windows PowerShell 5.0 Microsoft introduced new module Microsoft.PowerShell.Archive which has two commands Compress-Archive and Expand-Archive.
Help
help Compress-Archive -ShowWindow help Expand-Archive -ShowWindow |
Compress-Archive
Compress-Archive -Path 'C:\Temp\Windows PowerShell 5.0 for Developers _ TOC.docx' -DestinationPath C:\Temp\Test.zip -Verbose |
Compressed
Compression Level
We can compress the files or folders in three levels
- Fastest
- NoCompression
- Optimal
Expand Archive
Expand-Archive -Path C:\Temp\Test.zip -DestinationPath C:\Temp -Force |
Over here we used -Force Parameter because the file exists
help Expand-Archive -Parameter * |