The sz command is being run in an implicit InlineScript activity. It doesn’t have access to any of the variables and is probably prompting for something.
Thanks you for responses MSDN has shown me the root cause
"
Variables in InlineScript
By default, the variables that are defined in a workflow are not visible to the commands in the InlineScript script block. To make workflow variables visible to the InlineScript, use the $Using scope modifier.
The following example shows how to make the values of top-level workflow variables available to the commands in an inlineScript script block."
I don’t use workflows much, so I had to fiddle with this a bit. Here’s what appears to work for me in testing. (I don’t actually have 7-zip installed on this computer, so I just launched cmd.exe /c and echo’ed some text out to the .7z files as a test.)
$sourceFolder = 'C:\Source'
$tempZipFolder = 'C:\Source\Temp\'
#archive source files to volumes 1GB and save 7zfiles to temp folder
workflow Archive-Files {
param (
[string] $SourceFolder,
[string] $ZipFolder
)
$folder = dir $SourceFolder
# The files are processed in parallel.
foreach -parallel ($file in $folder)
{
InlineScript {
$Path=$using:file.FullName
$fileName=$using:file.Name
$basename=$using:file.Basename
$zippedFileName="$basename"+".7z"
$fullPathZippedFile= Join-Path $using:ZipFolder $zippedFileName
& "$env:ProgramFiles\7-Zip\7z.exe" a $fullPathZippedFile $Path -v1000M
}
}
}
Archive-Files -SourceFolder $sourceFolder -ZipFolder $tempZipFolder