How To Create and Extract Zip File Using Powershell

Published: 18 October 2018
on channel: Lockard
5,597
34

How to use Powershell command Compress-Archive to create a zip file.

How to use Powershell command Expand-Archive to extract a zip file.


#Create a zip file by selecting individual files.
$backup= Compress-Archive -LiteralPath C:\Users\Nick\Downloads\1.txt, C:\Users\Nick\Downloads\2.txt, C:\Users\Nick\Downloads\3.txt -CompressionLevel Optimal -DestinationPath C:\Users\Nick\Downloads\output\test-files.zip
$backup


#Create a zip file by selecting individual folders.
$backup= Compress-Archive -Path C:\Users\Nick\Downloads\sub1, C:\Users\Nick\Downloads\sub2 -CompressionLevel Optimal -DestinationPath C:\Users\Nick\Downloads\output\test-folders
$backup


#Add the contents of a folder and its sub folders to an existing zip file.
$backup= Compress-Archive -Path C:\Users\Nick\Downloads\extra\* -Update -DestinationPath C:\Users\Nick\Downloads\output\test-folders.zip
$backup


#Extract a zip file using full directory location path.
$backup= Expand-Archive -LiteralPath C:\Users\Nick\Downloads\output\test-files.zip -DestinationPath C:\Users\Nick\Downloads\restored
$backup


#Extract a zip file in the current working directory.
$backup= Expand-Archive -Path test-folders.zip -DestinationPath C:\Users\Nick\Downloads\restored
$backup

This video is brought to you by https://www.lockard.it


Watch video How To Create and Extract Zip File Using Powershell online without registration, duration hours minute second in high quality. This video was added by user Lockard 18 October 2018, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5,59 once and liked it 3 people.