none
PowerShell: get running timer jobs

    Question

  • Hi, all!

    I want to get a list of running at the moment timer jobs with powershell.

    I have tried googling but was not successfull. Is there any solid way to get this kind of list with powershell?

    Best regards!

    Tuesday, October 30, 2012 3:36 PM

All replies

  • I'm not aware of any Powershell to get running timer jobs.  However you could write something like this:

    # Get current date
    $date = Get-Date
    
    # Show current date
    Write-Host "Looking for running jobs with a Last Run Time of greater than or equal to" $date
    
    # Get all Timer jobs and iterate
    Get-SPTimerJob | ForEach-Object {
    
      # Get last run time for job
      $lastRunTime = $_.LastRunTime
    
      # If run time is greater than/equal to write it out
      if ($lastRunTime -ge $date)
      {
         Write-Host $_.Name", last run at" $_.LastRunTime
      }
    }


    Brandon Atkinson
    Blog: http://brandonatkinson.blogspot.com

    Tuesday, October 30, 2012 6:52 PM
  • Well, it does not do the trick:

    1) A timer job could have lasted less then a second and be launched after the the script was launched, but it was finished

    2) If timer job was started before this script was run but still is running it want be listed in the results.

    Wednesday, October 31, 2012 9:34 AM