Get-​Azure​Batch​Task

Gets the Batch tasks for a job.

Syntax

Get-AzureBatchTask
   [-JobId] <String>
   -BatchContext <BatchAccountContext>
   [-Expand <String>]
   [-Filter <String>]
   [-MaxCount <Int32>]
   [-Select <String>]
   [<CommonParameters>]
Get-AzureBatchTask
   [[-Job] <PSCloudJob>]
   -BatchContext <BatchAccountContext>
   [-Expand <String>]
   [-Filter <String>]
   [-MaxCount <Int32>]
   [-Select <String>]
   [<CommonParameters>]
Get-AzureBatchTask
   [-JobId] <String>
   [[-Id] <String>]
   -BatchContext <BatchAccountContext>
   [-Expand <String>]
   [-Select <String>]
   [<CommonParameters>]

Description

The Get-AzureBatchTask cmdlet gets Azure Batch tasks for a Batch job. Specify a job by either the JobId parameter or the Job parameter. To get a single task, specify the Id parameter. You can specify the Filter parameter to get the tasks that match an Open Data Protocol (OData) filter.

Examples

Example 1: Get a task by ID

PS C:\>Get-AzureBatchTask -JobId "Job01" -Id "Task03" -BatchContext $Context
AffinityInformation         : 
CommandLine                 : cmd /c dir /s
ComputeNodeInformation      : Microsoft.Azure.Commands.Batch.Models.PSComputeNodeInformation
Constraints                 : Microsoft.Azure.Commands.Batch.Models.PSTaskConstraints
CreationTime                : 7/25/2015 11:24:52 PM
DisplayName                 : 
EnvironmentSettings         : 
ETag                        : 0x8D295483E08BD9D
ExecutionInformation        : Microsoft.Azure.Commands.Batch.Models.PSTaskExecutionInformation
Id                          : Task03
LastModified                : 7/25/2015 11:24:52 PM
PreviousState               : Running
PreviousStateTransitionTime : 7/25/2015 11:24:59 PM
ResourceFiles               : 
RunElevated                 : False
State                       : Completed
StateTransitionTime         : 7/25/2015 11:24:59 PM
Statistics                  : 
Url                         : https://pfuller.westus.batch.azure.com/jobs/Job01/tasks/Task03

This command gets the task with ID Task03 under job Job01. Use the Get-AzureRmBatchAccountKeys cmdlet to assign a context to the $Context variable.

Example 2: Get all completed tasks from a specified job

PS C:\>Get-AzureBatchTask -JobId "Job02" -Filter "state eq 'completed'" -BatchContext $Context
AffinityInformation         : 
CommandLine                 : cmd /c dir /s
ComputeNodeInformation      : Microsoft.Azure.Commands.Batch.Models.PSComputeNodeInformation
Constraints                 : Microsoft.Azure.Commands.Batch.Models.PSTaskConstraints
CreationTime                : 3/24/2015 10:21:51 PM
EnvironmentSettings         : 
ETag                        : 0x8D295483E08BD9D
ExecutionInformation        : Microsoft.Azure.Commands.Batch.Models.PSTaskExecutionInformation
Id                          : Task17
LastModified                : 3/24/2015 10:21:51 PM
PreviousState               : Running
PreviousStateTransitionTime : 3/24/2015 10:22:00 PM
ResourceFiles               : 
RunElevated                 : False
State                       : Completed
StateTransitionTime         : 3/24/2015 10:22:00 PM
Statistics                  : 
Url                         : https://pfuller.westus.batch.azure.com/jobs/Job02/tasks/Task17

AffinityInformation         : 
CommandLine                 : cmd /c echo hello > newFile.txt
ComputeNodeInformation      : Microsoft.Azure.Commands.Batch.Models.PSComputeNodeInformation
Constraints                 : Microsoft.Azure.Commands.Batch.Models.PSTaskConstraints
CreationTime                : 3/24/2015 10:21:51 PM
EnvironmentSettings         : 
ETag                        : 0x8D295483E08BD9D
ExecutionInformation        : Microsoft.Azure.Commands.Batch.Models.PSTaskExecutionInformation
Id                          : Task27
LastModified                : 3/24/2015 10:23:35 PM
PreviousState               : Running
PreviousStateTransitionTime : 3/24/2015 10:23:37 PM
ResourceFiles               : 
RunElevated                 : True
State                       : Completed
StateTransitionTime         : 3/24/2015 10:23:37 PM
Statistics                  : 
Url                         : https://pfuller.westus.batch.azure.com/jobs/Job02/tasks/Task27

This command gets the completed tasks from the job that has the ID Job02.

Required Parameters

-BatchContext

Specifies the BatchAccountContext instance that this cmdlet uses to interact with the Batch service. To obtain a BatchAccountContext object that contains access keys for your subscription, use the Get-AzureRmBatchAccountKeys cmdlet.

Type:BatchAccountContext
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-JobId

Specifies the ID of the job that contains the tasks that this cmdlet gets.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Expand

Specifies an OData expand clause. Specify a value for this parameter to get associated entities of the main entity to get.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Filter

Specifies an OData filter clause for tasks. If you do not specify a filter, this cmdlet returns all tasks for the Batch account or job.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Id

Specifies the ID of the task that this cmdlet gets. You cannot specify wildcard characters.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Job

Specifies the job that contains tasks that this cmdlet gets. To obtain a PSCloudJob object, use the Get-AzureBatchJob cmdlet.

Type:PSCloudJob
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-MaxCount

Specifies the maximum number of tasks to return. If you specify a value of zero (0) or less, the cmdlet does not use an upper limit. The default value is 1000.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Select

Specifies an OData select clause. Specify a value for this parameter to get specific properties rather than all object properties.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Outputs

PSCloudTask