How to display the result of a function?

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 3 years, 1 month ago.

  • Author
  • #22543

    Mason Emlen

    I know how to invoke a function, but how do I display the function result on screen?

  • #22544

    Don Jones

    Whatever the function writes to the pipeline, by using Write-Output, will be returned as the result of the function. If nothing else is capturing that result, then it will display on the screen.

    Functions are a kind of PowerShell command, and can work very similarly to a cmdlet. So basically, you just run the function.

    function test {
      write-output "Hello"

You must be logged in to reply to this topic.