Just to provide clarity which I missed in my previous message, I am using the script in a custom command. Running it from the custom command itself.
Custom command setup

Custom command with script:

Script used in Custom command for testing:
$commandDN = "CN=Active Users report,CN=Users,CN=BC Custom Reports,CN=Reports,CN=Reports Root,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$parameterName = "param-departmentauto" # TOOD: modify me
$propertyName = "department" # TOOD: modify me
# Bind to the custom command
$command = $Context.BindToObjectByDN($commandDN)
$Context.LogMessage($command, "Information")
# Get parameter
$parameters = $command.Parameters
$parameter = $parameters | Where {$_.Name -eq $parameterName}
if ($NULL -eq $parameter)
{
$Context.LogMessage("Parameter '$parameterName' not found in Custom Command '$commandName'.", "Warning")
return
}
return
Current error when running the script from editor
