After investigating how to create a zip file with Powershell I found the following very helpful link which describes how to create a zip file using Powershell with the following line of script:
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
This works like a charm, problem is I simply don't understand how it works. Could I please get a breakdown of what this does?
By using ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
as the value to set-Content
, we are simply adding the file header and creating a 0 byte .zip
file.
To understand this, you may want to read under the section file headers:
Headers in ZIP files begin with "PK" (50 4B), the initials of Phil Katz, author of DOS compression utility PKZIP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With