我正在尝试使用7zip编写一个压缩文件的函数,但是我遇到了将多个参数传递给函数的问题 .
$In = "C:\test\gateways_25357_20140407000204.pcap"
$Out = "C:\test\gateways_25357_20140407000204.zip"
function CompressFile([string]$Output,[string]$Input) {
Write-Host $Output
write-host $Input
$7zipPath = "C:\Program Files\7-Zip\7z.exe"
$Arguments = "a","-tzip",$Output,$Input
& $7zipPath $Arguments
}
CompressFile $Out $In
我的代码结果是压缩此脚本的工作目录中的文件,输出转到正确的位置c:\ test .
通过传入$ Input参数,我到底做错了什么?
1 回答
$ Input是一个powershell自动变量,尝试更改名称 . 看到
http://technet.microsoft.com/en-us/library/hh847768.aspx