< Back

Import-DbaPfDataCollectorSetTemplate

Mon Jan 13, 2020 12:00 pm

NAME Import-DbaPfDataCollectorSetTemplate



SYNOPSIS

Imports a new Performance Monitor Data Collector Set Template either from the dbatools repository or a file you

specify.





SYNTAX

Import-DbaPfDataCollectorSetTemplate [[-ComputerName]

<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-Credential] <Pscredential>] [[-DisplayName]

<String>] [-SchedulesEnabled <Switch>] [[-RootPath] <String>] [-Segment <Switch>] [[-SegmentMaxDuration] <Int>]

[[-SegmentMaxSize] <Int>] [[-Subdirectory] <String>] [[-SubdirectoryFormat] <Int>] [[-SubdirectoryFormatPattern]

<String>] [[-Task] <String>] [-TaskRunAsSelf <Switch>] [[-TaskArguments] <String>] [[-TaskUserTextArguments]

<String>] [-StopOnCompletion <Switch>] [[-Path] <System.String[]>] [[-Template] <System.String[]>] [[-Instance]

<System.String[]>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Imports a new Performance Monitor Data Collector Set Template either from the dbatools repository or a file you

specify.



When importing data collector sets from the local instance, Run As Admin is required.



Note: The included counters will be added for all SQL instances on the machine by default.



For specific instances in addition to the default, use -Instance.



See https://msdn.microsoft.com/en-us/librar ... p/aa371952 for more information





PARAMETERS

-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target computer. Defaults to localhost.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Credential [<Pscredential>]

Allows you to login to servers using alternative credentials. To use:



$scred = Get-Credential, then pass $scred object to the -Credential parameter.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DisplayName [<String>]

Sets the display name of the data collector set.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.

This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables

advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Instance [<System.String[]>]

By default, the template will be applied to all instances. If you want to set specific ones in addition to the

default, supply just the instance name.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<System.String[]>]

The path to the xml file or files.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RootPath [<String>]

Sets the base path where the subdirectories are created.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SchedulesEnabled [<Switch>]

If this switch is enabled, sets a value that indicates whether the schedules are enabled.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Segment [<Switch>]

Sets a value that indicates whether PLA creates new logs if the maximum size or segment duration is reached

before the data collector set is stopped.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SegmentMaxDuration [<Int>]

Sets the duration that the data collector set can run before it begins writing to new log files.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SegmentMaxSize [<Int>]

Sets the maximum size of any log file in the data collector set.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-StopOnCompletion [<Switch>]

If this switch is enabled, sets a value that determines whether the data collector set stops when all the data

collectors in the set are in a completed state.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Subdirectory [<String>]

Sets a base subdirectory of the root path where the next instance of the data collector set will write its

logs.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SubdirectoryFormat [<Int>]

Sets flags that describe how to decorate the subdirectory name. PLA appends the decoration to the folder name.

For example, if you specify plaMonthDayHour, PLA appends the current month, day, and hour values to the folder

name. If the folder name is MyFile, the result could be MyFile110816.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SubdirectoryFormatPattern [<String>]

Sets a format pattern to use when decorating the folder name. Default is 'yyyyMMdd\\-NNNNNN'.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Task [<String>]

Sets the name of a Task Scheduler job to start each time the data collector set stops, including between

segments.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-TaskArguments [<String>]

Sets the command-line arguments to pass to the Task Scheduler job specified in the IDataCollectorSet::Task

property.

See https://msdn.microsoft.com/en-us/librar ... p/aa371992 for more information.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-TaskRunAsSelf [<Switch>]

If this switch is enabled, sets a value that determines whether the task runs as the data collector set user

or as the user specified in the task.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-TaskUserTextArguments [<String>]

Sets the command-line arguments that are substituted for the {usertext} substitution variable in the

IDataCollectorSet::TaskArguments property.

See https://msdn.microsoft.com/en-us/librar ... p/aa371993 for more information.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Template [<System.String[]>]

From one or more of the templates from the dbatools repository. Press Tab to cycle through the available

options.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Performance, DataCollector, PerfCounter

Author: Chrissy LeMaire (@cl), netnerds.net



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



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



PS C:\\>Import-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template 'Long Running Query'



Creates a new data collector set named 'Long Running Query' from the dbatools repository on the SQL Server sql2017.

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



PS C:\\>Import-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template 'Long Running Query' -DisplayName 'New

Long running query' -Confirm



Creates a new data collector set named "New Long Running Query" using the 'Long Running Query' template. Forces a

confirmation if the template exists.

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



PS C:\\>Get-DbaPfDataCollectorSet -ComputerName sql2017 -Session db_ola_health | Remove-DbaPfDataCollectorSet



Import-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template db_ola_health | Start-DbaPfDataCollectorSet



Imports a session if it exists, then recreates it using a template.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Get-DbaPfDataCollectorSetTemplate | Out-GridView -PassThru | Import-DbaPfDataCollectorSetTemplate

-ComputerName sql2017



Allows you to select a Session template then import to an instance named sql2017.

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Import-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template 'Long Running Query' -Instance

SHAREPOINT



Creates a new data collector set named 'Long Running Query' from the dbatools repository on the SQL Server sql2017

for both the default and the SHAREPOINT instance.



If you'd like to remove counters for the default instance, use Remove-DbaPfDataCollectorCounter.



RELATED LINKS

https://dbatools.io/Import-DbaPfDataCol ... etTemplate