C# strings to PowerShell Variable

hi all. I'm trying to build a GUI for my many different powershell scripts I have. Currently I'm trying to figure out how to take an input from a textbox in C# and make that to where it can be used in a powershell script. For instance, one script takes a list of employee logins and moves them to where they should be and assigned the correct group permissions. I'm trying to GUI this with radio buttons selected to determine what script runs.

string agents = richTextBox1.text 

is there a way where I can use this information directly with powershell the same way I would

$agents | foreach-object -dostuff? 

or if C# is not the best language to build a gui for powershell what should I be using?

edit: yes I did google before I asked in here. I can set up a runspace, just need to know how to make a C# string into a powershell object.

by domestic_omnom via /r/csharp

Leave a Reply