How to access an indexed property on a COM object from Powershell How to access an indexed property on a COM object from Powershell powershell powershell

How to access an indexed property on a COM object from Powershell


Item does work. You have to use Item() instead of Item[] and indices are 1-based.

$sched = New-Object -Com "Schedule.Service"$sched.Connect()$folder = $sched.GetFolder('\')$task = $folder.GetTask("Update Bin Dir")$triggers = $task.Definition.Triggers$triggers.Item(1)Type               : 2Id                 : 67a9fad4-462f-43d9-ab71-6e9b781966e6Repetition         : System.__ComObjectExecutionTimeLimit : StartBoundary      : 2007-07-02T05:30:00EndBoundary        : Enabled            : TrueDaysInterval       : 1RandomDelay        : 

Using an enumerator also works if you don't need to access by index:

foreach ($trigger in $triggers) { $trigger }


On my system, it looks like there is only one trigger being returned for some tasks. You might try forcing it to return in an array.

$sched = New-Object -Com "Schedule.Service"$sched.Connect()$folder = $sched.GetFolder('\')$task = $folder.GetTask("some task")$triggers = @($task.Definition.Triggers)$trigger = $triggers[0]