locked
power shell output is different when script is ran on maximized window and smaller window RRS feed

  • Question

  •   

    output is different when script is ran on maximized window and smaller window 
    for example 
    i ran this script in powershell 
    Select-String "C:\excel\output.csv" -pattern "| missing |" -SimpleMatch | select line | Format-list line | out-file C:\excel\new.txt 
    when power shell is maximized window size got below output:



    Line :             | MS11-025 | Missing | Security Update for Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package (KB2538243) | Important | 

    Line :             | MS16-109 | Missing | Security Update for Microsoft Silverlight (KB3182373) | Important | 



    when power shell is smaller window size got below output

    Line :             | MS11-025 | Missing | Security Update for Microsoft Visual C++ 2008 Service Pack 1 
           Redistributable Package (KB2538243) | Important | 

    Line :             | MS16-109 | Missing | Security Update for Microsoft Silverlight (KB3182373) | Important






     I  need output as single line as first output irrespective of powershell window size .. please help


    • Moved by Bill_Stewart Tuesday, October 18, 2016 2:31 PM Abandoned
    Sunday, September 18, 2016 7:40 PM

Answers

  • That is because you are using display size to control the output width:

    Select-String "C:\excel\output.csv" -pattern "| missing |" -SimpleMatch | select -expand line | out-file C:\excel\new.txt 


    \_(ツ)_/

    • Marked as answer by vishnusundar Monday, October 24, 2016 11:51 PM
    Sunday, September 18, 2016 9:38 PM

All replies

  • Yes.  That is correct.  That is how Windows works.  What did you expect?

    \_(ツ)_/

    Sunday, September 18, 2016 8:01 PM
  • i got different output.txt file 

    if powershell is in maximized windows, the output is single single lines as i expected.

    if powershell is in  smaller windows, first line ouput split into 2lines , 2nd line output comes on 3 line

    hope you understand the difference. IF not please share the email address so that i can share the output files with you


    Sunday, September 18, 2016 8:32 PM
  • That is because you are using display size to control the output width:

    Select-String "C:\excel\output.csv" -pattern "| missing |" -SimpleMatch | select -expand line | out-file C:\excel\new.txt 


    \_(ツ)_/

    • Marked as answer by vishnusundar Monday, October 24, 2016 11:51 PM
    Sunday, September 18, 2016 9:38 PM