I'm running Active Roles 7.4, the latest version. I've created a PowerShell Library script which contains a logging function I'd like to share with all the other Scheduled Task scripts I've written. Currently, the function is copy and pasted into each Scheduled Task Script, which isn't programming best practise.
However, I can't work out how to tell the Scheduled Task scripts how to use the Library Script. The error which the Scheduled Task gives is:
The term 'myCoolLoggingFunction' 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.
My Library Script looks like this (I've trimmed it for brevity):
# This function writes a log entry to a SQL table
function myCoolLoggingFunction([string]$source, [int]$severity, [string]$string, [string]$integer, [string]$dt, [string]$detail)
# No single quotes
$string = $string -replace '''', ''
It's more clear that to get this to work from a Policy Script, I'd call UseLibraryScript in the onInit function ... but I can't work out how to tell a Scheduled Task script to include the Library Script which Active Roles has let me create. Could you post a snippet of your code if you've got this to work?