Controller Script & Module

Welcome Forums General PowerShell Q&A Controller Script & Module

Viewing 1 reply thread
  • Author
    Posts
    • #200618
      Participant
      Topics: 17
      Replies: 24
      Points: 80
      Rank: Member

      Good day,

      Could someone please help with a little guidance.

      I recently built approximately 14 functions (12 public/ 2 private), however now i would like to create scheduled task on each server to execute the functions, then output the data to a sql database.

       

      I thought just create a control script to do this however i was wondering where i should store this?

      Inside a module folder or separate?

      Should i create a separate module imports the first module, creates a scheduled task on the server?

       

      Any suggestion or help would be greatly appreciated.

       

      Thank you

    • #200663
      Participant
      Topics: 12
      Replies: 1642
      Points: 2,660
      Helping Hand
      Rank: Community Hero

      IMHO, you should keep the module and the script separate. If you set up an internal repository, then you can host a module and script in a central location:

      https://docs.microsoft.com/en-us/powershell/scripting/gallery/how-to/working-with-local-psrepositories?view=powershell-7
      https://powershellexplained.com/2017-05-30-Powershell-your-first-PSScript-repository/

      Then you can create a script on your worker servers that will automatically update the module and script during execution:

      Task 1: Get the latest script

      Install-Script...
      

      Task 2: Execute PS1, something like:

      Install-Module -Name MyModule -Repository MyRepository -Scope CurrentUser
      Import-Module MyModule
      
      $stuff = Get-MyModuleStuff
      
      Invoke-SqlCmd ...
      
Viewing 1 reply thread
  • The topic ‘Controller Script & Module’ is closed to new replies.