共用方式為


Invoke-CMDataCollection

Applies To: System Center 2012 Configuration Manager Support Center

Invoke-CMDataCollection

Starts collecting data for a Configuration Manager client computer.

Syntax

Parameter Set: Default
Invoke-CMDataCollection [-CollectionTasks <DataCollector[]> ] [-MachineConnection <MachineConnection> ] [-OutputFile <String> ] [-PipelineVariable <String> ] [ <CommonParameters>]

Detailed Description

The Invoke-CMDataCollection cmdlet starts collecting data for a System Center 2012 Configuration Manager client computer. You can specify which data to collect and specify a file name for the data. Specify a connection to a client computer, either local or remote, that you create by using the New-CMMachineConnection cmdlet.

Parameters

-CollectionTasks<DataCollector[]>

Specifies an array of DataCollector objects that define the collection tasks to include in data collection. If you do not specify this parameter, the cmdlet uses the default set of collection tasks from the Configuration Manager client computer.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MachineConnection<MachineConnection>

Specifies a connection to a Configuration Manager client computer. If you do not specify this parameter, the cmdlet establishes the connection with the local computer.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OutputFile<String>

Specifies the name of the output file that the cmdlet uses to capture log files and other data collected about the Configuration Manager client computer. If you do not specify a name, the cmdlet uses a default file name.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PipelineVariable<String>

Specifies a variable to use with the pipeline operator.

Aliases

pv

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 (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Examples

Example 1: Start data collection

This example establishes a remote connection to a Configuration Manager client, gets data collection tasks, and starts data collection. The first command uses the ConvertTo-SecureString cmdlet to create a secure string based on the specified password, and then stores that string in the $Password variable. For more information, type Get-Help ConvertTo-SecureString.

The second command uses the New-CMMachineConnection cmdlet to create a connection to a remote computer by using the specified user name and the password stored in the $Password variable. The command verifies that it creates the connection.

The third command uses the Get-CMDataCollectionTasks cmdlet to get data collection tasks, and stores them in the $Tasks variable.

The final command uses the current cmdlet to start data collection of the tasks stored in $Tasks. The command specifies an output file.

PS C:\> $Password = ConvertTo-SecureString -AsPlainText -String "Password123" -Force
PS C:\> $Connection = New-CMMachineConnection -MachineName "Client01.corp.contoso.com" -UserName "CONTOSO\PattiFuller" -Password $Password -Verify
PS C:\> $Tasks = Get-CMDataCollectionTasks
PS C:\> Invoke-CMDataCollection -MachineConnection $Connection -CollectionTasks $Tasks -OutputFile "C:\DataCollection\Client01Data"

Get-CMDataCollectionTasks

New-CMMachineConnection