I'm having issues with retrieving task parameters in a scheduled task.
I'm running Version: 6.8.0.4269
I've tried the following two methods:
Method 1: As per:
function Get-Param($name)
{
foreach($v in $task.Dirobj.Parameters)
{
if ($v.name -eq $name)
{
$v.Value
break;
}
}
}
$OrgUnitToQuery = Get-Param("OrgUnitToQuery")
The debug info looks like this:
DEBUG: 123+ foreach($v in >>>> $task.Dirobj.Parameters)
Call '$Task.get_DirObj'
Call '$DirObj.Parameters'
DEBUG: ! SET $foreach = 'System.__ComObject System.__ComObject System.__ComObj...'.
DEBUG: 123+ foreach( >>>> $v in $task.Dirobj.Parameters)
DEBUG: ! SET $foreach = ''.
DEBUG: 131+ >>>> }
DEBUG: ! SET $OrgUnitToQuery = ''.
And the $OrgUnitToQuery value is blank.
If I added an eventlog entry in the ForEach block, but before the IF block, the EventLog is never fired (indicating to me that it THINKS that the object is empty.
Method 2: from the 6.8 SDK in the seciton titled: Using Parameters in Scheduled Task Scripts
$TestAuditOnly = $Task.DirObj.Parameters("TestAuditOnly")
And the script fails, and the debug info looks like this:
DEBUG: 164+ >>>> $TestAuditOnly = $Task.Dirobj.Parameters("TestAuditOnly")
Call '$Task.get_dirobj'
ERROR:
At Line: 164 char:1. Method invocation failed because [Quest.ActiveRolesServer.Service.CorePolicies.PowerShellDirObj] doesn't contain a method named 'Parameters'.
What am I missing? This is driving me batty.
P.S. The rest of the script functions fine when executing in PowerGUI.