Calling query results from Powershell into C#

Viewed 55

I am new to Powershell.

I am trying to insert the query results of this Powershell code into C# variable called "results".

I got the C# sample code from here to get the result of Powershell into C#.

var results = ps.Invoke();
foreach (var psobject in results)
{
  var myInteger = Convert.ToInt32(psobject.Members["SomeField"].Value);
}

By looking at this Powershell code, on line 39 and 40,

# results of query
[Intacct.SDK.Xml.OnlineResponse]$Response = $task.Result

the object name for the query results seems to be [Intacct.SDK.Xml.OnlineResponse]$Response. Is it?

1) What would be expression to get the result of this Powershell and put inside C#?

2) Do I have to install PowerShell Tool into Visual Studio to see the "PowerShell" object to be recognized (shows up without an error)?

And, why is this extension trial version?

enter image description here

enter image description here

I am trying to understand how powershell code works within C# solution.

3) Do I just create ps1 code like this and add to the solution? enter image description here Thank you.

0 Answers
Related