private void PrintPSOutput(PSDataCollection <PSObject> outputCollection) { foreach (PSObject outputItem in outputCollection) { // if null object was dumped to the pipeline during the script then a null // object may be present here. check for null to prevent potential NRE. if (outputItem != null) { string output = outputItem.BaseObject.ToString(); if (_verbose) { Console.WriteLine(output); } if (output.IndexOf("failed") > -1) { ReportErrors(outputCollection.Where(i => i != null).Select(i => $"{i.BaseObject.ToString()}")); } } } }