title: Retrieve Scheduled Task Trigger details via Powershell
body: <p>I am trying to create a Powershell script that pulls specific information about scheduled tasks from remote computers.  My goal to have this run weekly to export the information to keep documentation updated.  I have everything working except that the trigger information is generic <strong>(System.Xml.XmlElement)</strong> and I would like to have the summary that shows up when you open Task Scheduler <strong>(At 6:50 PM every day - After triggered, repeat every hour for a duration of 1 day.)</strong> come through.  The function I have so far is below.  I specifically need assistance with the Triggers.</p>
  
  <pre><code>function Get-TasktInfo {
    [cmdletbinding()]
    param (
     [Parameter(ValueFromPipeline=$True,position=0,mandatory=$true)]$AllFolders
     )
  PROCESS{
      foreach ($Folder in $AllFolders) {
          if (($Tasks = $Folder.GetTasks(1))) {
              $Tasks | Foreach-Object {
                   $xml = [xml]$_.xml;
                  New-Object -TypeName PSCustomObject -Property @{
                  'Name' = $_.name
                  'UserId' = ([xml]$_.xml).Task.Principals.Principal.UserID
                  'Triggers' = $(If($xml.task.triggers) {ForEach($task in ($xml.task.triggers | gm | Where{$_.membertype -eq "Property"})){$xml.task.triggers.$($task.name)}})
                  'Author' =  ([xml]$_.xml).Task.RegistrationInfo.Author
                  'Description' = ([xml]$_.xml).Task.RegistrationInfo.Description
                  'State' = switch ($_.State) {
                      0 {'Unknown'}
                      1 {'Disabled'}
                      2 {'Queued'}
                      3 {'Ready'}
                      4 {'Running'}
                      Default {'Unknown'}
                  }
                  'Actions' = ($xml.Task.Actions.Exec | % { "$($_.Command) $($_.Arguments)" }) -join "`n"
                  'Path' = $_.path
                  }
              }
          }
      }
  }
  END{
      return $Tasks
  }
  </code></pre>
  
  <p>}</p>