Creating .CAB files with Powershell

During our on-going development of online updateable Powershell help (more on that later) you quickly come to realise that each culture-specific set of help files is stored within its own 1980’s style cabinet (or .cab) file. When packing the .cab files for release, I like to automate (if you hadn’t already guessed!) as it makes things quick, easy and certainly less error prone.

Working with .cab files in Powershell requires use of MAKECAB.EXE which, fortunately, is distributed with each edition of Windows. In the good ol’ days we could use the MakeCab.MakeCab.1 COM object, but this has been deprecated since Windows Vista. I had a quick Google and couldn’t find anything easily reusable (except Ed Wilson’s post here) and thus this blog post.

I set to work, creating a Powershell advanced function that would easily allow me to package each culture-specific help file (or one or more files) into its own cabinet file. It would probably be more prudent to utilise .NET’s StringBuilder class but performance is not (currently) an issue or priority!

You never know I might come back and show you how we use this with Psake in the future… Here are some examples of how you can use it:

Here’s the full advanced function:

 

3 Comments

  1. John D Author June 13, 2016 (10:17 pm)

    This is going to save me so much time and effort, just want to say thanks for putting this out there. Not too many helpful resources for this type of material. Thanks again!

  2. Rajneesh Author January 23, 2017 (8:35 pm)

    This cuts my work to 1/10 when I need to create a CAB file. Amazing stuff. Thanks a Ton!!

Trackbacks & Pingbacks

  1. Migrating lists from SharePoint 2010 to 2013 using Export-SPWeb and Import-SPWeb | SAIAYA sharepoint September 3, 2015 (6:18 am)

Leave a Reply

Archives

Categories