How I could do this is to use a piece of PowerShell script and then βplayβ with the output in C #.
If you add a link to the following element, you can interact with PowerShell scripts in C #:
System.Management.Automation
Then use the following instructions to delve into and interact with the features of this:
using System.Collections.ObjectModel; using System.Management.Automation; using System.Management.Automation.Runspaces
The following script will create a good sub element that will take a PowerShell command and return a readable line, with each element (in this case, the role) added to a new line:
private string RunScript(string scriptText) {
Then you can pass the following PowerShell command to the script and get the output like this:
RunScript("Import-module servermanager | get-windowsfeature");
Alternatively, you can simply run this PowerShell command with a C # script and then read the output text file from C # when you finish processing the script:
import-module servermanager | get-windowsfeature > C:\output.txt
Hope this helps!
chrismason954
source share