Controller script

This topic contains 8 replies, has 6 voices, and was last updated by Profile photo of Jeff Jeff 3 weeks, 3 days ago.

  • Author
    Posts
  • #37981
    Profile photo of Graham Beer
    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
    Profile photo of Don Jones
    Don Jones
    Keymaster

    It would be indeed.

  • #38001
    Profile photo of Graham Beer
    Graham Beer
    Participant

    Awesome, thanks Don !

  • #39060
    Profile photo of Nick Barton
    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
      Profile photo of Jeff
      Jeff
      Participant

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

    • #57749
      Profile photo of Jeff
      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
    Profile photo of Mark Prior
    Mark Prior
    Participant

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

  • #57338
    Profile photo of Mark Prior
    Mark Prior
    Participant

    thanks Olaf

You must be logged in to reply to this topic.