12

I have replaced some of th ecomments with:

Write-Verbose "Doing somthing..."

and I run my script via PS ISE like:

.\FooScript.ps1 -verbose

But in the output window I do not see any of those messages.

How can I make the write-Verbose messages displayed?

pencilCake
  • 51,323
  • 85
  • 226
  • 363

1 Answers1

25

You need to add

[CmdletBinding()]

at the start of your script and use the

-verbose

parameter to see verbose messages.

Read more typing:

help about_functions_advanced
participant
  • 2,923
  • 2
  • 23
  • 40
CB.
  • 58,865
  • 9
  • 159
  • 159
  • You mean the top of the ps1 file? – pencilCake Nov 02 '12 at 13:45
  • 8
    @pencilCake yes! before the `param()` declaration. If you don't have a param add it as `param()` after `[CmdletBinding()]` – CB. Nov 02 '12 at 13:48
  • 1
    @pencilCake In ISE if you call a function with `[CmdletBinding()]` using paramenter `-verbose` it must works! – CB. Nov 02 '12 at 15:23