Create ZipFiles with Powershell |
|
I have used PCSX module in the past to write zipfiles. I wondered if there was a different way to do this. Of course the Scripting Guys had all the work already done. See the below link
http://blogs.technet.com/b/heyscriptingguy/archive/2015/03/09/use-powershell-to-create-zip-archive-of-folder.aspx
Here is my script. I plan to use this as a way to zip up backup files for archiving.
cls
<#
$source will contain the files you want to be zipped up. $source and $destination must not be located in the same directory
test-path to see if the zip file exists and remove if file exists
#>
$source = "C:\test"
$destination = "C:\test\test.zip"
If(Test-path $destination){Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($Source, $destination)
http://blogs.technet.com/b/heyscriptingguy/archive/2015/03/09/use-powershell-to-create-zip-archive-of-folder.aspx
Here is my script. I plan to use this as a way to zip up backup files for archiving.
cls
<#
$source will contain the files you want to be zipped up. $source and $destination must not be located in the same directory
test-path to see if the zip file exists and remove if file exists
#>
$source = "C:\test"
$destination = "C:\test\test.zip"
If(Test-path $destination){Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($Source, $destination)