How to display the result of a function?

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 2 years, 4 months ago.

  • Author
  • #22543
    Profile photo of Mason Emlen
    Mason Emlen

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

  • #22544
    Profile photo of Don Jones
    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.