Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6704301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:16:22+00:00 2026-05-26T07:16:22+00:00

The below script works fine and displays all the iformation I need – however,

  • 0

The below script works fine and displays all the iformation I need – however, there is a problem in displaying NETSH commands. So, normally in powershell if you enter the below:

netsh int tcp show global

It displays in the TABLe format as below:

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : disabled
Chimney Offload State               : disabled
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : disabled
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled

However, when I do this in a powershell script that logs to a LOG file the output is all scewed – ie the below:

Querying active state...  TCP Global Parameters ---------------------------------------------- Receive-Side Scaling State          : disabled  Chimney Offload State               : disabled  NetDMA State                        : disabled  Direct Cache Acess (DCA)            : disabled  Receive Window Auto-Tuning Level    : disabled  Add-On Congestion Control Provider  : none  ECN Capability                      : disabled  RFC 1323 Timestamps                 : disabled  

Any idea how I can keep the TABLE format that powershell command prompt displays?

Script:

 $computerdel = gc env:computername

 $t = "D:\temp\$(gc env:computername).log"
 #$e = Test-Path $t rm $t -ErrorAction SilentlyContinue

 #if ( $e -eq $true ) { rm $t }
 #else { Write-Host "Shortcut does not exist." }


 $Logfile = "D:\temp\$(gc env:computername).log"

 Function LogWrite {    Param ([string]$logstring)

    Add-content $Logfile -value $logstring }

 LogWrite
 -----------------------------------------------------------------------------------------------------------------------------------------------

 $Date = Get-Date

 LogWrite "Script has been run on $Date - This is Servers Local Time"
 LogWrite $computer = gc env:computername $onetcp = ((get-childitem
 c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductMajorPart).tostring()
 $twotcp = ((get-childitem
 c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductMinorPart).tostring()
 $threetcp = ((get-childitem
 c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductBuildPart).tostring()
 $fourtcp = ((get-childitem
 c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductPrivatePart).tostring()


 $onedfsr = ((get-childitem
 c:\windows\system32\dfsrs.exe).Versioninfo.ProductMajorPart).tostring()
 $twodfsr = ((get-childitem
 c:\windows\system32\dfsrs.exe).Versioninfo.ProductMinorPart).tostring()
 $threedfsr = ((get-childitem
 c:\windows\system32\dfsrs.exe).Versioninfo.ProductBuildPart).tostring()
 $fourdfsr = ((get-childitem
 c:\windows\system32\dfsrs.exe).Versioninfo.ProductPrivatePart).tostring()

 $hotfix1 = Get-HotFix -Id KB2450944 -ErrorAction SilentlyContinue
 $hotfix2 = Get-HotFix -Id KB2582284 -ErrorAction SilentlyContinue
 #$hotfix3 = Get-HotFix -Id KB979808 -ErrorAction SilentlyContinue

 LogWrite

 If ($hotfix2) {    LogWrite "Hotfix KB2582284 is installed - This is
 TCPIP.sys Upgrade Hotfix" -BackgroundColor Green -ForegroundColor
 Black  } else {    LogWrite "Hotfix KB2582284 is NOT installed - Please
 ensure you install this hotfix - This is DFSRS.exe Upgrade Hotfix"
 -ForegroundColor "red"     }

 LogWrite "TCPIP.sys Version on $computer is:
 ""$onetcp.$twotcp.$threetcp.$fourtcp"" " LogWrite If ($hotfix1) {
    LogWrite "Hotfix KB2450944 is installed - This is DFSRS.exe Upgrade
 Hotfix" -BackgroundColor Green -ForegroundColor Black  } else {
    LogWrite "Hotfix KB2450944 is NOT installed - Please ensure you
 install this hotfix - This is DFSRS.exe Upgrade Hotfix"
 -ForegroundColor "red"     }    LogWrite "DFSRS.exe Version on $computer is: ""$onedfsr.$twodfsr.$threedfsr.$fourdfsr"" "

 LogWrite

 If (get-wmiobject win32_share | where-object {$_.Name -eq "REMINST"})
 {   LogWrite "The REMINST share exists on $computer" } Else {  
 LogWrite "The REMINST share DOES NOT exist on $computer - Please
 create as per standards"  }  

 #If ($hotfix3) {
 #  LogWrite "Hotfix KB979808 is installed" -BackgroundColor Green -ForegroundColor Black
 #  }
 #else {
 #  LogWrite "Hotfix KB979808 is NOT installed - Please ensure you install this hotfix" -ForegroundColor "red"
 #}      LogWrite

 $u = "DBG\ADS-ALL-ROFS-Manager"; net localgroup "Distributed COM
 Users" | Where {$_ -match $u}

 If ($u) {  LogWrite "DBG\ADS-ALL-ROFS-Manager is part of Distributed
 COM Users localgroup on $computer"     } else {    LogWrite
 "DBG\ADS-ALL-ROFS-Manager is NOT part of Distributed COM Users
 localgroup on $computer"   } LogWrite $disabletaskoffload =
 Get-ItemProperty
 'HKLM:\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters' -Name
 'DisableTaskOffload' | fl  DisableTaskOffload -ErrorAction
 SilentlyContinue $EnableTCPChimney = Get-ItemProperty
 'HKLM:\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters' -Name
 'EnableTCPChimney' | fl  EnableTCPChimney $EnableTCPA =
 Get-ItemProperty
 'HKLM:\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters' -Name
 'EnableTCPA' | fl  EnableTCPA $EnableRSS = Get-ItemProperty
 'HKLM:\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters' -Name
 'EnableRSS' | fl  EnableRSS

 If ($disabletaskoffload) {     LogWrite "Registry Key DisableTaskOffload
 is set" -BackgroundColor Green -ForegroundColor Black  } else {
    LogWrite "Registry Key DisableTaskOffload is NOT set"
 -ForegroundColor "red"     }    If ($EnableTCPChimney) {   LogWrite "Registry Key EnableTCPChimney is set" -BackgroundColor Green
 -ForegroundColor Black     } else {    LogWrite "Registry Key EnableTCPChimney is NOT set" -ForegroundColor "red"  }    If
 ($EnableTCPA) {    LogWrite "Registry Key EnableTCPA is set"
 -BackgroundColor Green -ForegroundColor Black  } else {    LogWrite "Registry Key EnableTCPA is NOT set" -ForegroundColor "red"    }    If
 ($EnableRSS) {     LogWrite "Registry Key EnableRSS is set"
 -BackgroundColor Green -ForegroundColor Black  } else {    LogWrite "Registry Key EnableRSS is NOT set" -ForegroundColor "red"     } $netsh =
 netsh int tcp show global LogWrite LogWrite "***Running Netsh
 Check***" LogWrite "Ensure the following are set to disabled:"
 LogWrite "Receive-Side Scaling State: Disabled" LogWrite "Chimney
 Offload State: Disabled" LogWrite "Receive Window Auto-Tuning Level:
 Disabled" LogWrite LogWrite $netsh LogWrite
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:16:23+00:00Added an answer on May 26, 2026 at 7:16 am

    That’s because you LogWrite function simply converts its input to a string and “dumps” it to the log file. The simplest solution for you would be to replace it with appending | Out-File -Append <logfile> to each post you want to put in the log:

    >"Some message" | Out-File -Append <logfile>
    >netsh int tcp show global | Select-Object -skip 2 | Out-File -Append <logfile>
    

    will produce:

    Some message
    TCP Global Parameters
    ---------------------------------------------- 
    Receive-Side Scaling State          : enabled
    Chimney Offload State               : automatic
    NetDMA State                        : enabled
    Direct Cache Acess (DCA)            : disabled
    Receive Window Auto-Tuning Level    : normal
    Add-On Congestion Control Provider  : none
    ECN Capability                      : disabled
    RFC 1323 Timestamps                 : disabled
    

    (The Select-Object is a simple way to skip some beginning lines from output)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following script works fine: $(#regform).validate().showErrors({username:message}); After I changed the script to the below
The below code works fine for only the first click event. However for any
It's my first time dealing with cookies in JavaScript and the below script works
The script below will replace selected word in a textarea. But it only works
When there is no files inside the folder the below script goes inside the
Jquery stopPropagation method dosen't work with live method. Below the code is works fine
The jQuery ajax script below doesn't work on my site if url is without
I have tested the below script on a demo page which is not using
I've tried the below script but I am getting an error: dim cn, rs
The script below, test.php, is intended to be placed in a specific directory of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.