You are not logged in.

#1 23 Oct 2018 13:54

xcabur
New Member
Registered: 23 Oct 2018
Posts: 4

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: 4

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

#4 01 Dec 2018 18:47

xcabur
New Member
Registered: 23 Oct 2018
Posts: 4

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

Sorry for my late respons, I was on Holiday. Thank you very much, I had the same workaround at the end. However, this only worked when I started a new PowerShell process, increasing the buffer size of the current "script process" had no effect on the output of dcdiag.

Offline

#5 02 Dec 2018 18:25

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

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

xcabur wrote:

Sorry for my late respons, I was on Holiday. Thank you very much, I had the same workaround at the end. However, this only worked when I started a new PowerShell process, increasing the buffer size of the current "script process" had no effect on the output of dcdiag.

This could be because you are running DCDiag as an elevated process, so you will need to change the BufferWidth in the same elevated process.

Offline

Board footer

Powered by