Thor Logo dbatools

Invoke-DbaPfRelog

View Source
Chrissy LeMaire (@cl), netnerds.net
Windows, Linux, macOS

Synopsis

Pipeline-compatible wrapper for the relog command which is available on modern Windows platforms.

Description

Pipeline-compatible wrapper for the relog command. Relog is useful for converting Windows Perfmon.

Extracts performance counters from performance counter logs into other formats,
such as text-TSV (for tab-delimited text), text-CSV (for comma-delimited text), binary-BIN, or SQL.

relog "C:\PerfLogs\Admin\System Correlation\WORKSTATIONX_20180112-000001\DataCollector01.blg" -o C:\temp\foo.csv -f tsv

If you find any input hangs, please send us the output so we can accommodate for it then use -Raw for an immediate solution.

Syntax

Invoke-DbaPfRelog
    [[-Path] <String[]>]
    [[-Destination] <String>]
    [[-Type] <String>]
    [-Append]
    [-AllowClobber]
    [[-PerformanceCounter] <String[]>]
    [[-PerformanceCounterPath] <String>]
    [[-Interval] <Int32>]
    [[-BeginTime] <DateTime>]
    [[-EndTime] <DateTime>]
    [[-ConfigPath] <String>]
    [-Summary]
    [[-InputObject] <Object[]>]
    [-Multithread]
    [-AllTime]
    [-Raw]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Invoke-DbaPfRelog -Path C:\temp\perfmon.blg

Creates C:\temp\perfmon.tsv from C:\temp\perfmon.blg.

Example: 2
PS C:\> Invoke-DbaPfRelog -Path C:\temp\perfmon.blg -Destination C:\temp\a\b\c

Creates the temp, a, and b directories if needed, then generates c.tsv (tab separated) from C:\temp\perfmon.blg.
Returns the newly created file as a file object.

Example: 3
PS C:\> Get-DbaPfDataCollectorSet -ComputerName sql2016 | Get-DbaPfDataCollector | Invoke-DbaPfRelog -Destination C:\temp\perf

Creates C:\temp\perf if needed, then generates computername-datacollectorname.tsv (tab separated) from the latest logs of all data collector sets on sql2016. This destination format was chosen to
avoid naming conflicts with piped input.

Example: 4
PS C:\> Invoke-DbaPfRelog -Path C:\temp\perfmon.blg -Destination C:\temp\a\b\c -Raw
>> [Invoke-DbaPfRelog][21:21:35] relog "C:\temp\perfmon.blg" -f csv -o C:\temp\a\b\c
>> Input

##### >> 
>> File(s):
>> C:\temp\perfmon.blg (Binary)
>> Begin:    1/13/2018 5:13:23
>> End:      1/13/2018 14:29:55
>> Samples:  2227
>> 100.00%
>> Output

##### >> 
>> File:     C:\temp\a\b\c.csv
>> Begin:    1/13/2018 5:13:23
>> End:      1/13/2018 14:29:55
>> Samples:  2227
>> The command completed successfully.

Creates the temp, a, and b directories if needed, then generates c.tsv (tab separated) from C:\temp\perfmon.blg then outputs the raw results of the relog command.

Example: 5
PS C:\> Invoke-DbaPfRelog -Path 'C:\temp\perflog with spaces.blg' -Destination C:\temp\a\b\c -Type csv -BeginTime ((Get-Date).AddDays(-30)) -EndTime ((Get-Date).AddDays(-1))

Creates the temp, a, and b directories if needed, then generates c.csv (comma separated) from C:\temp\perflog with spaces.blg’, starts 30 days ago and ends one day ago.

Example: 6
PS C:\> $servers | Get-DbaPfDataCollectorSet | Get-DbaPfDataCollector | Invoke-DbaPfRelog -Multithread -AllowClobber

Relogs latest data files from all collectors within the servers listed in $servers.

Example: 7
PS C:\> Get-DbaPfDataCollector -Collector DataCollector01 | Invoke-DbaPfRelog -AllowClobber -AllTime

Relogs all the log files from the DataCollector01 on the local computer and allows overwrite.

Optional Parameters

-Path

Specifies the file path to Windows performance counter log files (.blg format) that need to be converted. Accepts multiple file paths and supports pipeline input.
Use this when you have perfmon binary logs that need to be converted to readable formats like CSV or TSV for analysis.

PropertyValue
AliasFullName
RequiredFalse
Pipelinetrue (ByPropertyName)
Default Value
-Destination

Specifies the output file path or directory where converted performance data will be saved. Creates necessary directories automatically if they don’t exist.
When omitted, files are saved in the same directory as the source with the appropriate extension (.tsv, .csv, etc.).

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Type

Specifies the output format for the converted performance data. Defaults to ’tsv’ (tab-separated values).
Use ‘csv’ for Excel compatibility, ’tsv’ for easy parsing in PowerShell, ‘bin’ for binary format, or ‘sql’ to write directly to a SQL database via ODBC.
For SQL output, specify the destination as ‘DSN!counter_log’ where DSN is configured in ODBC Manager.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Valuetsv
Accepted Valuestsv,csv,bin,sql
-Append

Appends performance data to an existing output file instead of overwriting it. Only works with binary (-Type bin) format.
Use this when consolidating multiple perfmon logs into a single file for comprehensive analysis over time periods.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-AllowClobber

Overwrites existing output files without prompting. Required when the destination file already exists and you want to replace it.
Use this in automated scripts or when you need to refresh converted performance data files.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-PerformanceCounter

Specifies specific performance counters to extract from the log files. Accepts counter paths like ‘\Processor(_Total)% Processor Time’.
Use this to filter large perfmon logs and extract only the counters you need for analysis, reducing output file size.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-PerformanceCounterPath

Specifies a text file containing performance counter paths to extract, one counter per line. Alternative to specifying counters directly.
Use this when you have a standard set of counters for monitoring SQL Server performance and want to consistently extract the same metrics across multiple log files.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Interval

Specifies the sampling interval by including every nth data point from the original log. Reduces output size by skipping intermediate samples.
Use this when working with high-frequency perfmon logs where you need less granular data for trend analysis rather than detailed monitoring.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value0
-BeginTime

Specifies the start time for data extraction using a DateTime object. Only performance data from this time forward will be included in the output.
Use this to extract specific time periods from large perfmon logs, such as during a known performance incident or maintenance window.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-EndTime

Specifies the end time for data extraction using a DateTime object. Performance data after this time will be excluded from the output.
Combine with BeginTime to extract data from specific time ranges, useful for analyzing performance during particular events or time periods.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-ConfigPath

Specifies a configuration file containing relog command-line parameters for complex or frequently-used conversion settings.
Use this when you have standardized performance log processing requirements that need consistent parameters across multiple operations.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Summary

Displays summary information about the performance log files including available counters and time ranges without performing the conversion.
Use this to examine perfmon logs before processing them, helping you determine what counters are available and the time span covered.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-InputObject

Accepts data collector objects from Get-DbaPfDataCollector and Get-DbaPfDataCollectorSet via pipeline input for automatic log file discovery.
Use this to convert performance logs directly from active or configured data collectors without manually specifying file paths.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByValue)
Default Value
-Multithread

Processes multiple performance log files in parallel to improve performance when converting large batches of files.
Use this when converting many perfmon logs simultaneously, especially beneficial on multi-core systems with large performance monitoring datasets.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-AllTime

Processes all available log files from data collectors instead of just the most recent ones when used with pipeline input from Get-DbaPfDataCollector.
Use this when you need to convert historical performance data from all collection periods, not just the latest monitoring session.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-Raw

Displays the raw output from the relog command instead of returning file objects. Useful for debugging conversion issues or seeing detailed progress.
Use this when troubleshooting relog operations or when you need to see the exact command-line output and statistics from the conversion process.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-EnableException

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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse