Я пытаюсь выполнить простую команду powershell в c # и вывести результат.Powershell v5.1 на сервере 2016
PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-DhcpServerInDC");
Collection<PSObject> results = ps.Invoke();
StringBuilder sb = new StringBuilder();
foreach (PSObject obj in results) {
sb.AppendLine(obj.ToString()); }
txt_adt_updateTextbox.Text = sb.ToString();
Но вместо того, чтобы получить список DHCP-серверов и их IP-адресов, я получаю следующее.
DhcpServerInDC DhcpServerInDC DhcpServerInDC DhcpServerInDC DhcpSpInverDhcpServerInDC DhcpServerInDC DhcpServerInDC DhcpServerInDC DhcpServerInDC DhcpServerInDC DhcpServerInDC