Skip to content

Built in functionality for scripts

Environment

Easit ProcessRunner have a "companion" module called 'Easit.ProcessRunner.GlobalFunctions' for anyone to use in their script to get some variables and functionality "by default". This module does not affect the default loading of the PowerShell profile or modules for the user as when you start PowerShell as normal. The module can be installed by running the command below.

1
    C:\Users\administrator> Install-Module -Name 'Easit.ProcessRunner.GlobalFunctions' -Scope AllUsers

OR this as the user running the Easit ProcessRunner service.

1
    C:\Users\eprServiceUser> Install-Module -Name 'Easit.ProcessRunner.GlobalFunctions'

By running the command Set-EPREnvironment in your script the following variables will be made available.

  • epr_Directory
  • epr_logsDirectory
  • epr_scriptsDirectory
  • epr_scriptSettingsDirectory
  • epr_scriptHelpersDirectory
  • epr_modulesDirectory
  • epr_customModulesDirectory
  • epr_customFunctionsDirectory
  • ScriptLogName
  • epr_LoggerSettings

In addition to the variables mentioned above the environment script accepts 2 named parameters.

  • CustomModules
  • Modules

All these parameters accepts a string as input in the following syntax.

Example 1

1
    C:\Users\administrator> Set-EPREnvironment -CustomModules "MyModule","AnotherModule"

This would import two modules from scripts/helpers/customModules named MyModule and AnotherModule. As the Modules parameter is omitted, modules from that folder will NOT be imported.

Example 2

1
    C:\Users\administrator> Set-EPREnvironment

This would only create the variables mentioned above and NOT import any modules or custom modules.

Example 3

1
    C:\Users\administrator> Set-EPREnvironment -IncludeOldVariableNames

This would only create the variables mentioned above, NOT import any modules or custom modules and create variables named easitPR* as it would by using environmentSetup.ps1.

Any modules located in the PSModulePath will be loaded, and profile scripts will run, when the PowerShell process starts as it normally would.