Reputation: 78
Is there a way to just get the Time of a ScheduledJob Trigger?
I run the following command:
$jobTrigger = Get-ScheduledJob -Name MyJob | Get-JobTrigger
And the contents of $jobTrigger becomes:
ID Frequency Time DaysOfWeek Enabled
-- --------- ---- ---------- -------
1 Once 2/8/2014 11:59:00 AM True
What I need to do is just capture the value of the time column in a variable so it looks something like this:
PS > $time
2/8/2014 11:59:00 AM
Note: There will always only be one row in $jobTrigger
Upvotes: 0
Views: 239
Reputation: 2448
Late to the party once more, but I ran across this while searching similar questions.
I found this will work as the OP requires. It will select the Name of the scheduled Job plus the Job-Trigger's time.
Get-ScheduledJob | Select Name,@{Name="Time";Expression={(Get-ScheduledJob | Select -ExpandProperty JobTriggers).At}}
Use Get-ScheduledJob | Select -ExpandProperty JobTriggers | Select -Property *
to check the NoteProperty for AT
Upvotes: 0
Reputation: 36322
You already have the time, it's an element of $jobTrigger. You just need to reference:
$jobTrigger.Time
Or, if having all of the elements really bothers you I suppose you could select only the Time property when assigning $jobTrigger ala:
$jobTrigger = (Get-ScheduledJob -Name MyJob | Get-JobTrigger).time
Sorry, I didn't realize that Time was a calculated response. Use the At property.
$jobTrigger.at
or
$jobTrigger = (Get-ScheduledJob -Name MyJob | Get-JobTrigger).at
Upvotes: 1