none
Executing custom function on remote servers RRS feed

  • Question

  • i have custom functions list, and another config file that is going to be used by the functions, my goal is to run those functions on remote servers, considering that some functions call other function from within them that's why i can't use the method below to call functions that are loaded in the local session.

    invoke-command -scriptblock ${function:foo}

    is it possible to make a module out of it and then make that module get imported automatically on system boot rather than user logon.
    any suggestions on how to accomplish the main goal ?

    Monday, March 6, 2017 6:32 AM

Answers

  • Module only load when PowerShell is run.  They are not loaded into the system.

    Modules in the modules path will load automatically when any command in the module is referenced.

    help about_modules


    \_(ツ)_/

    • Marked as answer by Vagho Monday, March 6, 2017 10:34 AM
    Monday, March 6, 2017 7:23 AM

All replies

  • Module only load when PowerShell is run.  They are not loaded into the system.

    Modules in the modules path will load automatically when any command in the module is referenced.

    help about_modules


    \_(ツ)_/

    • Marked as answer by Vagho Monday, March 6, 2017 10:34 AM
    Monday, March 6, 2017 7:23 AM
  • Did you read the help?  It explains all of this in detail.

    \_(ツ)_/

    Monday, March 6, 2017 9:14 AM
  • is it possible to add my module in the default modules repository so that Powershell loads them automatically when the function is being called ? 

    You can use Powershell profile to import module when powershell is starting up.

    man about_profiles

    e.g. to add all available modules add to your profile following string:

    Get-Module -ListAvailable| Import-Module -PassThru -ErrorAction SilentlyContinue


    my blog: http://shserg.ru/


    • Edited by s.h.s. _ Monday, March 6, 2017 9:15 AM
    Monday, March 6, 2017 9:14 AM