PowerShell命令'write-zip'不起作用

我正在使用Powershell脚本将某些文件压缩为.zip文件。 我的整个脚本如下所示:

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

该脚本位于名为compress.ps1的文件中。 当我在命令行提示符时,我可以inputpowershell -file compress.ps1 ,它工作正常。 但是,如果我尝试从“Windows PowerShell ISE”运行脚本,则不起作用。 显示提示(“创buildZip文件”和“完成”)。 但是,我没有看到我的文件系统上的.zip文件。 如果我从Windows资源pipe理器中右键单击compress.ps1并select“使用Windows PowerShell打开”,也会发生同样的问题。

我究竟做错了什么? 感谢您提供的任何见解!

注意你的工作目录。 尝试指定文件的完全合格的path名称,而不仅仅是他们的短名称,看看会发生什么。