private static PowershellCommandDiagnosticData FromCommand(Command command, bool includeParameterValues)
        {
            PowershellCommandDiagnosticData powershellCommandDiagnosticData = new PowershellCommandDiagnosticData();

            powershellCommandDiagnosticData.CommandName = command.CommandText;
            IEnumerable <KeyValuePair <string, object> > source = includeParameterValues ? command.Parameters.Select(new Func <CommandParameter, KeyValuePair <string, object> >(PowershellCommandDiagnosticData.CommandParametersWithValues)) : command.Parameters.Select(new Func <CommandParameter, KeyValuePair <string, object> >(PowershellCommandDiagnosticData.CommandParametersWithoutValues));

            powershellCommandDiagnosticData.Parameters = source.ToArray <KeyValuePair <string, object> >();
            return(powershellCommandDiagnosticData);
        }
 public static PowershellCommandDiagnosticData[] FromPSCommand(PSCommand command, bool includeParameterValues)
 {
     return((from cmd in command.Commands
             select PowershellCommandDiagnosticData.FromCommand(cmd, includeParameterValues)).ToArray <PowershellCommandDiagnosticData>());
 }