Controller script

This topic contains 8 replies, has 6 voices, and was last updated by  Jeff 1 year ago.

  • Author
    Posts
  • #37981

    Graham Beer
    Participant

    I watched and enjoyed Don's 3 videos on toolmaking. Don refers to a 'controller script'. Would this be a script that calls a bunch of functions ?

  • #37982

    Don Jones
    Keymaster

    It would be indeed.

  • #38001

    Graham Beer
    Participant

    Awesome, thanks Don !

  • #39060

    Nick Barton
    Participant

    any good examples out there in the wild to reference. I know there are bunch of different ways to collect inputs and start calling functions just curious to see preferences/examples of how MVPs like yourself do it.

    • #57323

      Jeff
      Participant

      Yeah, me too. It's a clear way forward, but I'm not sure how to go about it...

    • #57749

      Jeff
      Participant

      Nick

      I'm not saying this is the BEST way of doing it, but it works, and seems reasonably elegant to me (with much credit to members of the Powershell forum in the Spiceworks community, particularly tfl):

      Do
      {
          $FirstName = .\Get-UserFirstName.ps1
      } Until ($FirstName)
      
      Do
      {
          $LastName = .\Get-UserLastName.ps1
      } Until ($LastName)
      
      $Title="Enter Telephone Extension Number"
      Do
      {
          $Extension = .\Get-UserExtension.ps1 -verbose -Title $Title
      } Until ($Extension)
      
      Write-Output "Child scriptS gave me '$FirstName' and '$LastName', and extension number '$Extension'"

      And here's the first script, Get-UserFirstName.ps1:

      Function Get-UserFirstName
      {
      $FirstName = Read-Host -Prompt "First Name"
      
      return $FirstName
      }
      
      Get-UserFirstName
  • #57334

    Mark Prior
    Participant

    dont think i have came across those vids, could you share a link(s)

  • #57338

    Mark Prior
    Participant

    thanks Olaf

You must be logged in to reply to this topic.