Power Shell Command Output not displayed in ASP.Net Textbox
I create ASP.Net webform application using MS VS 2015. According to code, I install System.Management.Automation library from NuGet packages.
And I'm trying to display my MQTT service command output in asp textbox. After click on ExecuteCode button, Code not showing error but output not showing.
page showing loading symbol in top corner of tab continuously. PowerShell command works at PowerShell console IDE as well.
I hope you solutions for that.
My PowerShell Command as:
mosquitto_sub -h 192.168.8.184 -p 1883 -t "topic"
protected void ExecuteCode_Click(object sender, EventArgs e)
{
ResultBox.Text = string.Empty;
var shell = PowerShell.Create();
shell.Commands.AddScript(Input.Text);
var results = shell.Invoke();
if (results.Count > 0)
{
var builder = new StringBuilder();
foreach (var psObject in results)
{
builder.Append(psObject.BaseObject.ToString() + "\r\n");
}
ResultBox.Text = Server.HtmlEncode(builder.ToString());
}
}