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:
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.
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
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.