#1 23 Oct 2018 13:54

xcabur
New Member
Registered: 23 Oct 2018
Posts: 2

Capture output without line break due to console buffer size

Hi all

I capture the console ouput of dcdiag with the following command:

$out = & dcdiag /test:VerifyEnterpriseReferences

Now, the $out contains a linebreak probably due to the console default screen buffer size width (80). The output looks like this

Doing primary tests

   Testing server: Site1\DC1
      Starting test: VerifyEnterpriseReferences
         ......................... DC1 passed test
         VerifyEnterpriseReferences

instead of this

Doing primary tests

   Testing server: Site1\DC1
      Starting test: VerifyEnterpriseReferences
         ......................... DC1 passed test VerifyEnterpriseReferences

Parsing the output is the problem. Is there a way to capture the output before it is rendered by the console?

thanks a lot

Offline

#2 23 Oct 2018 13:59

xcabur
New Member
Registered: 23 Oct 2018
Posts: 2

Re: Capture output without line break due to console buffer size

Parsing problem example:

$out[32]
         ......................... ADSPS001 passed test
$out[34]
         VerifyEnterpriseReferences

instead of

$out[32]
         ......................... ADSPS001 passed test VerifyEnterpriseReferences

Offline

#3 12 Nov 2018 13:14

Pyprohly
Member
Registered: 26 Nov 2014
Posts: 37

Re: Capture output without line break due to console buffer size

The solution here would be to increase the console buffer width before executing the command. Thankfully, programmatically setting the console buffer size is easily done in PowerShell.

[Console]::BufferWidth = 4096

Offline

Board footer

Powered by FluxBB