powershell functions

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Tim Pringle Tim Pringle 1 year, 6 months ago.

  • Author
  • #24155
    Profile photo of Sanjaya Luintel
    Sanjaya Luintel

    i have 5 functions copy-files, compare-files, alert-users, zip-files and remove-files.

    they look like this:
    function copy-file {
    param ($a,$b)
    copy-item $a $b

    how do I create 1 script, that will go through the entire functionslist one after the other?

  • #24156
    Profile photo of Ondrej Zilinec
    Ondrej Zilinec

    You define functions in first place and then you call them 🙂
    Or I missed your point in question?

  • #24160
    Profile photo of Tim Pringle
    Tim Pringle

    Hey Sanjaya,

    You'd want to do something like this

    function copy-file 
        param ($a,$b)
        Copy-Item $a $b
    #put your functions here e.g.
    function functionname
        param ($a,$b)
        command $a $b
    #put your other commands here including the parameters, like :
    copy-file -a $a -b $b

You must be logged in to reply to this topic.