This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is it possible to load Library Script in Scheduled Task using PowerShell ?

I have a large library of powershell functions that I would like to store in ARS as a library script and then call them from individual Scheduled Tasks, such as email, formatting, etc. I have attempted to add them Library Scripts but continually get an error such as "The term 'xfucntion' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

I see posts in regards to this but they appear old, maybe I am missing something?

Here is an example:

https://www.quest.com/community/b/en/posts/using-library-scriptsa-inside-ars-powershell-scheduled-tasks-scripts#

 

Thank you for any responses....

Cheers!

-JN

  • You should be able to do this using something like this in your scheduled task script:

    $context.UseLibraryScript("LibraryScriptName")

    I'm not 100% sure if the AR constant $Context is available in a scheduled task script.

    If it isn't, what you might be able to do as a workaround is instead of using a Scheduled Task to fire your code, use a script activity housed inside a scheduled AR Workflow. $Context should be available to you there.
  • I have used this in the past, built in solution would be preferrable as the SDK and KB Article indicate the only way to do it is VB Script

    $objScriptModule = [adsi]"EDMS://CN=Function Library,CN=Script Modules,CN=Configuration"

    $objScriptModule.RefreshCache("edsaScriptText")

    $libraryFunctionText = [string]($objScriptModule.edsaScriptText)

    Invoke-Expression $libraryFunctionText