How to get list of folders from Schedule.Service in powershell

I have a powershell script that lists the tasks in the root folder of task scheduler.

I can hard code sub folders, but I would like to be able to query the sub folders so it will work when new folders are added. Can this be done and, if so, how?

The relevant bit of script showing hard coded sub folder "Reports" being accessed:

$sch = New-Object -ComObject("Schedule.Service")
$tasks = $sch.GetFolder("\Reports").GetTasks(0)
$tasks | ForEach-Object{


Never mind - figured it out:

$root = $sch.GetFolder("\")
$subfolders = $root.GetFolders(0)
$subfolders | foreach-object{
  $tasks = $_.GetTasks(0)

Need Your Help

Mock a superclass constructor

java junit guice mockito jmock

I would like to know if I can mock a super class constructors call and its super() calls.

How can I reach parent module variable from "required" module in Titanium?

javascript titanium titanium-modules

I want to reach login information from submodules. How can I From subModules can we reach parent module's, callee's variables?