You can use Compress-Archive and Expand-Archive PowerShell cmdlets to zip and unzip files or folders in PowerShell. Here is a quick example for your reference –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
## Create a new zip file from the content of a folder Compress-Archive -Path C:\Windows\System32\drivers\etc -DestinationPath $HOME\system_backup.zip ## Add more files to your zip file reg export HKLM $HOME\HKLM.reg Compress-Archive -Path $HOME\HKLM.reg -Update -DestinationPath $HOME\system_backup.zip ## Check if the archive is created Get-ChildItem -Path $HOME ## Unzip the Zip file Expand-Archive -Path $HOME\system_backup.zip -DestinationPath $HOME\system_backup ## Check if the archive is created Get-ChildItem -Path $HOME\system_backup |