41

Whenever I want to test execution of my script in the PowerShell ISE, the entire script gets echoed to the console before it executes. Then, any actual output from the script gets written starting on a line immediately afterward. This puts a lot of noise in the console, and can make it tricky to find where the script echo ends and the output begins.

Is there a way to disable this echoing of the script into the console?

Iszi
  • 14,163

3 Answers3

55

Save the script at least once. This will prevent the "script echo" of contents of the script. Instead, it will only echo the path to the saved script when you run the script for testing.

SgtOJ
  • 7,397
8

If you just want to make the onscreen output 'cleaner', just add:

cls

at the top of your powershell script. This will clear the output in the console. The script will still be written onscreen momentarily but it will be cleared as soon as your code actually starts executing.

-3

if you have a line, for example

cmd.exe /c "echo foo"

you can path it into null and therefore produce no output

cmd.exe /c "echo foo" > $null

so if you launch your .ps1 from the command line you can do something like this:

PS C:\Users\bodyi> foo.ps1 > $null
Kuro
  • 9