# if $commands is a folder if(test-path $c -pathtype container) { # get each textfile in the root level directory of the folder passed $files = @(Get-ChildItem "$c\*.*" -include *.txt -errorAction "SilentlyContinue") foreach($file in $files) { $tempcommands = @(Get-Content $file) foreach($tc in $tempcommands) { $commands += $tc } } } else { # Read in list of commands from passed named parameter $commands = @(Get-Content $c) } # Run commands foreach ($command in $commands) { Write-Output "+--------------------------------+" Write-Output "Running Command: $command" Write-Output "+--------------------------------+" try { $scriptblock = $ExecutionContext.InvokeCommand.NewScriptBlock($command) $out = Invoke-Command -computer $computer -scriptblock $scriptblock
$a = get-content @(jobs\a.txt) $b = get-content @(jobs\b.txt) $c = $a + $b (note i've also tried $a += $b here!) foreach($i in $c) { "new line $i" }