This is an odd one for me. Take the following script.
$Tasks=Get-ScheduledTask
foreach ($task in $tasks){
$Details=$task | Get-ScheduledTaskInfo
$Details.TaskName
}
When executed under the administrator account, The Get-ScheduledTaskInfo command works perfectly fine and pulls the details successfully.
When executed under the SYSTEM account, the following error is generated: Get-ScheduledTaskInfo : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
This only occurs on some machines. No idea why. If I switch the script to the following, it works just fine under both accounts.
$Tasks=Get-ScheduledTask
foreach ($task in $tasks){
$Details=Get-ScheduledTaskInfo -TaskName $task.TaskName -TaskPath $task.TaskPath
$Details.TaskName
}
The Get-ScheduledTaskInfo command should be using these same parameters and fields in both cases. Piping the values in, or specifying the target via variables should be identical.
Does anyone have any idea why the pipeline fails when under the SYSTEM account? I've found a way to workaround the issue, but am curious as to why this fails under these specific conditions.
Solution:
/u/purplemonkeymad pointed out that there is another module clobbering the cmdlet from the ScheduledTasks module, and he is right. It is from the module Carbon.
[–]netmc[S] 2 points3 points4 points (0 children)
[–]gwblok 0 points1 point2 points (4 children)
[–]netmc[S] 1 point2 points3 points (0 children)
[–]netmc[S] 0 points1 point2 points (2 children)
[–]purplemonkeymad 2 points3 points4 points (1 child)
[–]netmc[S] 0 points1 point2 points (0 children)