0

I am attempting to write a function to compress files using 7zip, but I am having issues passing multiple parameters to the function.

$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

My results of this code is the compressing of the files in the working directory of this script and the output goes to the correct location c:\test.

What exactly am I doing wrong here with passing in the $Input parameter?

1 Answer 1

2

$Input is a powershell automatic variable, try changing the name. see

$In = "C:\test\gateways_25357_20140407000204.pcap"
$Out = "C:\test\gateways_25357_20140407000204.zip"


function CompressFile([string]$Outputz, [String]$Inputz) {
    Write-Host $Outputz
    write-host $Inputz
}
Write-Host $Out
write-host $In
CompressFile $Out $In

http://technet.microsoft.com/en-us/library/hh847768.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.