angelman0401
New member
- Joined
- Aug 17, 2022
- Messages
- 2
- Programming Experience
- 5-10
Hello all. I am new to C# and am trying to run the following code into a button's click event.
What I need is to display each object into the desired textbox. I am able to display a single object into the desired checkbox with this code,
I have six textboxes for each of the objects I want to display, but I need help doing so. Thanks for any assistance that anyone can provide.
C#:
using (PowerShell powerShell = PowerShell.Create())
{
powerShell.AddScript("Get-ComputerInfo | Select-Object CsDNSHostName,WindowsProductName, OSVersion, CSDomainRole, CSProcessors, OsProductType");
powerShell.AddCommand("Out-String");
Collection<PSObject> PSOutput = powerShell.Invoke();
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject pSObject in PSOutput)
stringBuilder.AppendLine(pSObject.ToString());
Tab2TxtBox2.Text = stringBuilder.ToString(); }
What I need is to display each object into the desired textbox. I am able to display a single object into the desired checkbox with this code,
C#:
powerShell.AddScript("Get-ComputerInfo | Select-Object CsDNSHostName -expand CsDNSHostName -unique);
I have six textboxes for each of the objects I want to display, but I need help doing so. Thanks for any assistance that anyone can provide.