I know how to execute a single powershell command and view the results of it using C# code. But I want to know how to execute a set of related commands as below and get the output:
$x = some_commandlet
$x.isPaused()
Simply, I want to access the return value of $x.isPaused().
How do I add this functionality to my C# application?
For such commands, it is better that you create something called pipeline and feed it your script. I have found a good example of this. You can find further about this code and such projects here.
This method is neatly done with proper comments. Also you can directly go to the link of Code Project I gave download it and start playing!