How to display the result of a function?

Welcome Forums General PowerShell Q&A How to display the result of a function?

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
3 years, 8 months ago.

  • Author
    Posts
  • #22543

    Participant
    Points: 0
    Rank: Member

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

  • #22544

    Keymaster
    Points: 3
    Rank: Member

    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"
    }
    test
    

The topic ‘How to display the result of a function?’ is closed to new replies.