Eliminating RawView from the powershell script result.

  • Thread starter Thread starter Nikul Vyas
  • Start date Start date
N

Nikul Vyas

Guest
I have a function that invokes the powershell script and returns the output. The problem is the output is returning multiple records and an additional raw view of blank record. How to eliminate it from the returned output.

Here's my function:

public List<string> PowerShellExecutorGrd(string scriptPath, string arg)
{
string outString = "";
var shell = PowerShell.Create();
shell.Commands.AddCommand(scriptPath).AddArgument(arg);
var results = shell.Invoke();
if (results.Count > 0)
{
var builder = new StringBuilder();
foreach (var psObj in results)
{
builder.Append(psObj.ToString().Trim('@').Trim('{').Trim('}') + "\n\r");
}
outString = Server.HtmlEncode(builder.ToString());
}
List<string> strLst = outString.Split(new char[] { '\n' }).ToList();
shell.Dispose();
return strLst;
}

1449399.jpgThe problem is when I am loading the records in the container table it is creating additional row for raw view as a blank record.

1449403.jpg

Is there a way to eliminate it in the function or through the script?

Continue reading...
 
Back
Top