Competition: What’s your favorite Redgate tool? Enter now.

Create native Windows Zip File using PowerShell

While developing some custom deployment scripts I had a need to create a ZIP archive of the current deployment (using PreDeploy.ps1) because we deploy into the same folder each time (i.e. not taking full advantage of the way Deployment Manager normally creates a <version> type hierarchy).

This was easy at first, I found some PowerShell code to create the archive, but then I realised it was an asynchronous process meaning the PS script carried on even though the archive was still being created. I tried the usual native PS tools for starting jobs, etc, but that didn't work. After some hunting I found this amazing PS code that starts the archive then loops until the exclusive lock has been released on the zip file but also checks the number of files compressed to ensure no files were skipped.

I've spoken with Alex Yates who suggested I post a link to the website so here you go:

I'm not going to paste the code here but I am going to post a comment on that blog post to see if it's possible to attach the code in case the post is lost in the future.
Sign In or Register to comment.