CmdID

CmdID / PowerShell / Cmdlets / Import

Import-Counter

Imports performance counter log files and creates the objects that represent each counter sample in the log. PowerShell reference

From the PowerShell reference 7 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Imports performance counter log files and creates the objects that represent each counter sample in the log. The Import-Counter cmdlet imports performance counter data from performance counter log files and creates objects for each counter sample in the file. The PerformanceCounterSampleSet objects that it creates are identical to the objects that Get-Counter returns when it collects performance counter data. You can import data from comma-separated value (.csv), tab-separated value (.tsv), and binary performance log (.blg) performance log files. If you are using .blg files, you can import up to 32 files in each command. You can use the parameters of Import-Counter to filter the data that you import. Along with the Get-Counter and Export-Counter cmdlets, this feature lets you collect, export, import, combine, filter, manipulate, and re-export performance counter data within Windows PowerShell.

Import-Counter [-Path] <String[]> [-StartTime <DateTime>] [-EndTime <DateTime>] [-Counter <String[]>] [-MaxSamples <Int64>] [<CommonParameters>]
Import-Counter [-Path] <String[]> -ListSet <String[]> [<CommonParameters>]
Import-Counter [-Path] <String[]> [-Summary] [<CommonParameters>]

Import all counter data from a file

$data = Import-Counter -Path ProcessorData.csvIdentify

Import specific counter data from a file

$i = Import-Counter -Path "ProcessorData.blg" -Counter "\\SERVER01\Processor(_Total)\Interrupts/sec"Identify

Select data from a performance counter then export it to a file

$data = Import-Counter .\ProcessorData.blg $data[0].CounterSamples | Format-Table -Property PathIdentify

Display all counter paths in a group of imported counter sets

Import-Counter -Path ProcessorData.csv -ListSet *Identify

Import counter data from a range of timestamps

Import-Counter -Path ".\disk.blg" | Format-Table -Property Timestamp $start = [datetime]"7/9/2008 3:47:00 PM"; $end = [datetime]"7/9/2008 3:47:59 PM" Import-Counter -Path Disk.blg -StartTime $start -EndTime $endIdentify

Import a specified number of the oldest samples from a performance counter log file

Import-Counter -Path "Disk.blg" -MaxSamples 5 (Import-Counter -Path Disk.blg)[-1 .. -5]Identify

Get a summary of counter data from a file

Import-Counter "D:\Samples\Memory.blg" -SummaryIdentify

Update a performance counter log file

$counters = Import-Counter OldData.blg -ListSet * | ForEach-Object {$_.PathsWithInstances} Get-Counter -Counter $Counters -MaxSamples 20 | Export-Counter C:\Logs\NewData.blgIdentify

Import performance log data from multiple files and then save it

$counters = "D:\test\pdata.blg", "D:\samples\netlog.blg" | Import-CounterIdentify

Its page in the reference: Import-Counter.

Parameters

7 in the PowerShell reference
-CounterSpecifies, as a string array, the performance counters. By default, Import-Counter imports all data from all counters in the input files. Enter one or more counter paths. Wildcards are permitted in the Instance part of the path. Each counter path has the following format. The ComputerName value is required in the path. For instance: - \<ComputerName>\<CounterSet>(<Instance>)<CounterName> For example: - \\Server01\Processor(2)\% User Time - \\Server01\Processor(*)\% Processor Time
-EndTimeSpecifies an end date and time that this cmdlet imports counter data between the StartTime and this parameter timestamps. Enter a DateTime object, such as one created by the Get-Date cmdlet. By default, Import-Counter imports all counter data in the files specified by the Path parameter.
-ListSetSpecifies the performance counter sets that are represented in the exported files. Commands with this parameter do not import any data. Enter one or more counter set names. Wildcards are permitted. To get all counter sets in the file, type Import-Counter -ListSet *.
-MaxSamplesSpecifies the maximum number of samples of each counter to import. By default, Get-Counter imports all of the data in the files specified by the Path parameter.
-PathSpecifies the file paths of the files to be imported. This parameter is required. Enter the path and file name of a, .csv, .tsv, or .blg file that you exported by using the Export-Counter cmdlet. You can specify only one .csv or .tsv file, but you can specify multiple .blg files (up to 32) in each command. You can also pipe file path strings (in quotation marks) to Import-Counter.
-StartTimeSpecifies the start date and time in which this cmdlet gets counter data. Enter a DateTime object, such as one created by the Get-Date cmdlet. By default, Import-Counter imports all counter data in the files specified by the Path parameter.
-SummaryIndicates that this cmdlet gets a summary of the imported data, instead of getting individual counter data samples.