while (!$Process.HasExited){ #Write-Host $Process.StandardOutput.ReadLine() $splitString = $Process.StandardOutput.ReadLine() -split "/1.1`" " if ($splitString[1]) { Write-Host $splitString[1].Substring(0, 3) $datarow = 5 if ($splitString[1].Substring(0, 3) -eq "500") { $data = $ExcelWorkSheet.Cells.Item($datarow,1).Value2 #500 errors if ($data) { $data = [int]$data + 1 } else { $data = 1 } $ExcelWorkSheet.Cells.Item($datarow,1) = $data Write-Host $data } if ($splitString[1].Substring(0, 3) -eq "200") { $data = $ExcelWorkSheet.Cells.Item($datarow,2).Value2 #200 errors if ($data) { $data = [int]$data + 1 } else { $data = 1 } $ExcelWorkSheet.Cells.Item($datarow,2) = $data Write-Host $data } } }