Forum Discussion

WSHvly01's avatar
WSHvly01
Copper Contributor
Feb 07, 2024

Script Output Format

The scripts I create normally have output on what it's doing and the status of it. I put the script under the Software Library Workspace > Scripts section. After running the script on a computer, I notice that the output of my script do not have any carriage returns or line feeds. Does anyone know how to get them to display? A simple test I did was use this script:

 

Write-Host "1"
Write-Host "2`r`n"
Write-Host "3"
Write-Output "4"
Write-Output "5`r`n"
Write-Output "6"

 

 

The output shows like this:

 

1 2  3 ["4","5\r\n","6"]

 

 

  • Garth-MVP's avatar
    Garth-MVP
    Iron Contributor
    My guess is they are being stripped out to allow for the script results to be showed nicely when run against a collection. Why problem requires multiple lines?
    • WSHvly01's avatar
      WSHvly01
      Copper Contributor

      Garth-MVP 

      The script outputs what it's doing, so that's why it has multiple lines. It's normal for a script to have multiple lines of output.

      • Garth-MVP's avatar
        Garth-MVP
        Iron Contributor
        I'm going to disagree with you. Almost all non interactive scripts only have one output as there is no way for ConfigMgr or LANDesk or ... To determine the results.

Resources