Powershell Script to Zip Files

compressionpowershell

I'm new to Powershell. I have a need that I assumed that it would be perfect for. However, I've quickly come to the point where I feel I'm in over my head. Basically, I need to create a .zip file.

I have a directory that looks like the following:

MyStuff
  Dir1
    Child1
      File1.txt
    Child2
      File1.png
    Child3
      File1.txt
  Dir2
    File1.txt
  File1.txt
  File2.txt
  File3.txt
  ...

I need to create a .zip file named bundle.zip. Bundle.zip should NOT have all of the files inside of MyStuff. Instead, I need to include MyStuff/File1.txt, MyStuff/File2.txt, MyStuff/File3.txt, and MyStuff/Dir1/* into the .zip file. I have no idea how to do this with PowerShell.

I have PowerShell v1.0 installed on my machine. I've been trying "Write-Zip" from the PowerShell Community Extensions, however, I get an error that says: "The term 'Write-Zip' is not recognized as the name of a cmdlet, function, script file, or operable program".

What am I doing wrong?

Best Answer

You need to download the Powershell Community Extension compatible with your installed Powershell version and install the same. Once the installation is done You need to move the PSCX module from the Program files location to the Powershell Module and then try using Write-Zip command.

https://pscx.codeplex.com/releases/view/133199