PowerShell Command ‘write-zip’ doesn’t work

compressionpowershell

I am using a Powershell script to compress some files into a .zip file. My entire script looks like this:

Write-Host "Creating Zip File... " -NoNewLine
write-zip ("file1.txt", "file2.txt", "file3.txt", "logs") log.zip
Write-Host "Done"

This script is in a file named compress.ps1. When I am at a command line prompt, I can enter powershell -file compress.ps1 and it works perfectly. However, if I attempt to run the script from the "Windows PowerShell ISE", it doesn't work. The prompts ("Creating Zip File", and "Done") are shown. However, I don't see the .zip file on my file system. This same problem happens if I just right-click on compress.ps1 from Windows Explorer and choose to Open With Windows PowerShell.

What am I doing wrong? Thank you for any insights you can provide!

Best Answer

Mind your working directory too. Try specifying the fully qualified path names of the files instead of just their short names and see what happens.