Name
Get-JobSchedulerTaskLog
SYNOPSIS
Read the task log from the JobScheduler History.
SYNTAX
Get-JobSchedulerTaskLog [-TaskId] <String> [[-Job] <String>] [[-StartTime] <DateTime>] [[-EndTime] <DateTime>] [[-ExitCode] <Int32>] [[-State] <PSObject>] [[-Criticality] <String>] [[-JobSchedulerId] <String>] [[-ClusterMember] <String>] [<CommonParameters>]
DESCRIPTION
Reads a task log for a given task ID. This cmdlet is mostly used for pipelined input from the
Get-JobSchedulerTaskHistory cmdlet that allows to search the execution history of tasks and
that returns task IDs that are used by this cmdlet to retrieve the task's log output.
PARAMETERS
TaskId
-TaskId <String>
Specifies the ID that the task was running with. This information is provided by the
Get-JobSchedulerTaskHistory cmdlet.
Required? | true |
Position? | 1 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
Job
-Job <String>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 2 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
StartTime
-StartTime <DateTime>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 3 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
EndTime
-EndTime <DateTime>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 4 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
ExitCode
-ExitCode <Int32>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 5 |
Default value | 0 |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
State
-State <PSObject>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 6 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
Criticality
-Criticality <String>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 7 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
JobSchedulerId
-JobSchedulerId <String>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 8 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
ClusterMember
-ClusterMember <String>
This parameter is used to accept pipeline input from the Get-JobSchedulerTaskHistory cmdlet and forwards the parameter to the resulting object.
Required? | false |
Position? | 9 |
Default value | |
Accept pipeline input? | true (ByValue, ByPropertyName) |
Accept wildcard characters? | false |
RELATED LINKS
EXAMPLES
-------------------------- EXAMPLE 1 --------------------------
PS > Get-JobSchedulerTaskHistory -Job /some/job174 | Get-JobSchedulerTaskLog
Retrieves the most recent task log for the given job.
-------------------------- EXAMPLE 2 --------------------------
PS > Get-JobSchedulerTaskHistory -Job /some/job174 | Get-JobSchedulerTaskLog | Out-File /tmp/job174.log -Encoding Unicode
Writes the task log to a file.
-------------------------- EXAMPLE 3 --------------------------
PS > Get-JobSchedulerTaskHistory -RelativeDateFrom -8h | Get-JobSchedulerTaskLog | Select-Object @{name='path'; expression={ "/tmp/history/$(Get-Date $_.startTime -f 'yyyyMMdd-hhmmss')-$([io.path]::GetFileNameWithoutExtension($_.job)).log"}}, @{name='value'; expression={ $_.log }} | Set-Content
Read the logs of tasks that completed within the last 8 hours and writes the log output to individual files. The log file names are created from the start time and the job name of each task.
-------------------------- EXAMPLE 4 --------------------------
PS > # execute once
$lastHistory = Get-JobSchedulerTaskHistory -RelativeDateFrom -8h | Sort-Object -Property startTime
# execute by interval
Get-JobSchedulerTaskHistory -DateFrom $lastHistory[0].startTime | Tee-Object -Variable lastHistory | Get-JobSchedulerTaskLog | Select-Object @{name='path'; expression={ "/tmp/history/$(Get-Date $_.startTime -f 'yyyyMMdd-hhmmss')-$([io.path]::GetFileNameWithoutExtension($_.job)).log"}}, @{name='value'; expression={ $_.log }} | Set-Content
Provides a mechanism to subsequently retrieve previous logs. Starting from intial execution of the Get-JobSchedulerTaskHistory cmdlet the resulting $lastHistory object is used for any subsequent calls. Consider use of the Tee-Object cmdlet in the pipeline that updates the $lastHistory object that can be used for later executions of the same pipeline. The pipeline can e.g. be executed in a cyclic job.