Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Precede with `&`.

Here is a complicated end portion of a script to build a "call" command and execute

#Configure Default Params
$SCRIPT="C:\tmp test\print_file.ps1"
$SCRIPT = Get-ChildItem $SCRIPT | % { $_.FullName }
$FilePathWithQuotes = '"{0}"' -f $SCRIPT
#Must Define 1 Print Server minimum
$DefParams = @(
       [pscustomobject]@{VarName="PRINTSRV";VarVal="NABV001"}
       [pscustomobject]@{VarName="DUPLEXPRINTSRV"; VarVal="NABV002"}
   )
#Don't Edit Below This Line
$DefArgs = "" ; $DefParams | ForEach-Object{IF ($_.VarVal) {$DefArgs += " -" + $_.VarName + ' "' + $_.VarVal + '" '}}
$PRINTCMD = "" ; $PrintFiles | ForEach-Object {$PRINTCMD = "&$FilePathWithQuotes $DefArgs -FILEPATH " + '"' + $_.FILEPATH + '" ' + $_.OptArgs ; $PRINTCMD ; Invoke-Expression $PRINTCMD}
  • No labels