When running Connect-NcController and then Invoke-NcSysstat -node <nodename> from a PS command line, it returns the standard output like in the documentation. Includes the node name, CPU %, various protocol stats, etc etc on a single line updating on the 5 second interval as would be expected. However when you run this from within a powershell script, the results are very much different. I have looked at all the PS settings and environment variables and found no differences so far. Wondering if anyone else has ran into this by chance or knows of a workaround to prevent it? The client is Win7 and Toolkit version 3.1
A PS script determines some info as to how many nodes a cluster has and then executes the following line:
The cmdlet runs just fine, but the output is completely weird compared to any documentation that I have seen. This resulting output in the newly created powershell window is listed below. I am trying to discover why this output is so drastically different when Invoke-NcSysstat is called within a script versus when it is ran on a command line, and hopefully find a workaround if anyone else has ran into this issue before.
When running commands in a script, any objects written to the pipeline are automatically sent to the default output formatter. The Connect-NcController command writes the controller object to the pipeline, which is written to the console in a table format. The Invoke-NcSysstat also writes objects to the pipeline, but they are not controller objects, so they do not fit into the controller table that had been created. As a result, the sysstat objects are written as a list. There are a few ways to change this.
1) You could capture the output of Connect-NaController into a variable. Then you can use Write-Host to write a message to the console indicating the connection context. For example:
$controller = Connect-NaController <IP>
Write-Host "Connected to $($controller).Name"
2) You could direct the output of Connect-NaController to Out-Null so it is not written at all. For example:
Connect-NaController <IP> | Out-Null
3) You can direct Invoke-NcSysstat to format-table to force the table formatting. For example: