Share via


Start-SCOMTask

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Start-SCOMTask

Starts a task against a specified object.

Syntax

Parameter Set: Empty
Start-SCOMTask [-Instance] <EnterpriseManagementObject> [-Task] <ManagementPackTask> [[-TaskCredentials] <PSCredential> ] [[-Override] <Hashtable> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Start-Task cmdlet starts a task against a specified object. This cmdlet requires a task object and a class instance object. This cmdlet accepts only one task, but can accept multiple class instances and overrides.

Parameters

-Instance<EnterpriseManagementObject>

Specifies one or more class instance objects for which to start a task. Enter a variable that represents the class instances, or type a command that gets the class instances. This parameter also accepts group objects.

For information about how to get a class instance object, type Get-Help Get-SCOMClassInstance.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Override<Hashtable>

Specifies a hash table that defines the values for one or more overridable parameters of the task being run. To determine the overridable parameters for a task, use the GetOverrideableParameters() method for a task object.

A hash table is a compact data structure that stores one or more name/value pairs. To create a hash table that defines the values for overridable parameters, use the following syntax:

@{
Parameter1=10;
Parameter2="1092834098123407953912837"}

To use a hash table in a command or script, save it in a variable. For example:

PS C:\> $Overrides = @{
>> Parameter1=10;
>> Parameter2="1092834098123407953912837"
>> }

For more information about hash tables, type Get-Help about_Hash_Tables.

Aliases

none

Required?

false

Position?

4

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Task<ManagementPackTask>

Specifies a task object to start. Enter a variable that represents the task, or type a command that gets the task. This parameter accepts only one task.

For information about how to get a task object, type Get-Help Get-SCOMTask.

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-TaskCredentials<PSCredential>

Specifies the credentials under which the task will run. If this parameter is omitted, the current user's credentials are used.

Aliases

none

Required?

false

Position?

3

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before executing the command.

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Describes what would happen if you executed the command without actually executing the command.

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters

Examples

-------------------------- EXAMPLE 1 --------------------------

Description

-----------

The first command gets all class instances in the Contoso.com domain and stores them in the $Instances variable.

The second command gets the task with the display name "Get Monitor State" and starts the task for each class instance stored in the $Instances variable.

PS C:\>$Instances = Get-SCOMClassInstance -Name *.Contoso.com
PS C:\>Get-SCOMTask -DisplayName "Get Monitor State" | Start-SCOMTask -Instance $Instances

-------------------------- EXAMPLE 2 --------------------------

Description

-----------

The first command creates a hash table with a value for the Timeout parameter and stores it in the $Overrides variable.

The second command gets all class instances with the name "Contoso Service" and stores them in the $Instances variable.

The third command gets the task with the display name "Start NT Service" and starts the task for each class instance stored in the $Instances variable.

The fourth command starts the task for each class instance stored in the $Instances variable using a Timeout parameter of 60.

PS C:\>$Overrides = @{Timeout=60}
PS C:\>$Instances = Get-SCOMClassInstance -DisplayName "Contoso Service"
PS C:\>$Task = Get-SCOMTask -DisplayName "Start NT Service"
PS C:\>Start-SCOMTask -Task $Task -Instance $Instances -Override $Overrides

-------------------------- EXAMPLE 3 --------------------------

Description

-----------

The first command prompts the user for a user name and password, and stores the credential object in the $Creds variable.

The second command gets a class instance named "Server01.Contoso.com" and stores it in the $Instance variable.

The third command gets a task with the display name "Reset State" and starts the task for the class instance stored in the $Instance variable. The command runs the task under the credentials stored in the $Creds variable.

PS C:\>$Creds = Get-Credential
PS C:\>$Instance = Get-SCOMClassInstance -Name Server01.Contoso.com
PS C:\>Get-SCOMTask -DisplayName "Reset State" | Start-SCOMTask -Instance $Instance -TaskCredentials $Creds

Get-SCOMClassInstance

Get-SCOMTask

Get-SCOMTaskResult