Home > OS >  Unwanted powershell output trimming
Unwanted powershell output trimming

Time:01-01

Trying to read and parse DNS cache in batch file, but in output of command

powershell Get-DnsClientCache

is trimmed to fit in screen. So trying to avoid trimming by Out-String -999

powershell "Get-DnsClientCache | out-string -width 999"

but this prevent only some columns from trimming, but not all of them. How could I print all columns in its full width to be parsed by batch script?

CodePudding user response:

What about Opening the Cmd Window MAXIMIZED and adding Format-Table -Autosize ?


@echo off
Title Get-DnsClientCache
@REM OPEN CMD WINDOW MAXIMIZED
IF NOT "%1"=="MAX" START /MAX CMD /D /C "%~0" MAX & GOTO :EOF 
Powershell -C "Get-DnsClientCache | Format-Table -AutoSize | out-string -width 999"
Pause
  • Related