Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to combine tables and filter date column

Status
Not open for further replies.

Powerbie

Technical User
Mar 20, 2012
1
US
Hello Im trying to write a script that can do 2 things. give me a list of the last jobs that ran, and the name and status of the jobs.
i've created 2 small scripts that have all the fields i need

i have 2 tables, repjobs and jobs.
repjobs contains a field that has the jobname, and templateID.
Jobs contains all the jobs that ran today( start time, end time, parent ID, and status)
code:
Code:
$today = get-Date -Format d
$jobs = @(
get-Job |
  Select-Object ParentJobTemplateID, StartedOn, CompletedOn, JobState, JobStatus  |
  Where-Object {$_.CompletedOn -like "*$today*"}
  Sort-Object CompletedOn -Descending
  )
$jobs
Code:
$repjobs = @(get-Jobtemplate| Select-Object IsEnabled, JobName, TemplateVersionID )

$repjobs
the thing is that there are 5 jobs, and they run multiple times through out the day. I want to be able to see the most recent status per job, and then look up the name of that job by matching parent ID with job ID from the repjobs table

I'm totally a newbie so getting this far took me a while, it would be most appreciated if someone could show me how this is done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top