We're using the following Powershell script to split the rows of a CSV in separate jobs but since we've updated Switch this script returns error:
Code: Select all
Job failed because outcode is nonzero, outcode = [1]
Code: Select all
param([string]$prefix, [string]$basepath, [string]$inputfile, [int]$split=1 );
$filename = "notset";
$tussenvoegsel = "";
import-CSV $inputfile -Header IP1,IP2,IP3,IP4,IP5,IP6,IP7,IP8,IP9,IP10 -Delimiter "," | Foreach-Object{
$headers = (get-content $inputfile)[0] -split ','
if ($_.IP1 -eq $headers[0]) {
}
else{
if ($_.IP2.length -gt 0) {
$tussenvoegsel = $_.IP2+ " "; }
else
{$tussenvoegsel = "";}
$filename =$prefix + "__" + $_.IP1 + " " + $tussenvoegsel + $_.IP3 + "-" + $_.IP9.replace("/","_") ;
Write-Host $_.IP1 $_.IP2 $filename
$headers[0]+","+$headers[1]+","+$headers[2] +","+$headers[3] +","+$headers[4] +","+$headers[5] +","+$headers[6]+","+$headers[7] +","+$headers[8] +","+$headers[9] +"`r`n" + $_.IP1 + "," + $_.IP2 + "," + $_.IP3 + "," + $_.IP4 + "," + $_.IP5 + "," + $_.IP6 + "," + $_.IP7 + "," + $_.IP8 + "," + $_.IP9 + "," + $_.IP10| Out-File $basepath$filename.csv
}
}
Anybody have an idea how to fix this? I'm not familiar with Powershell.
Thanks in advance!