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
What it does
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.csvIdentifyImport specific counter data from a file
$i = Import-Counter -Path "ProcessorData.blg" -Counter "\\SERVER01\Processor(_Total)\Interrupts/sec"IdentifySelect data from a performance counter then export it to a file
$data = Import-Counter .\ProcessorData.blg
$data[0].CounterSamples | Format-Table -Property PathIdentifyDisplay all counter paths in a group of imported counter sets
Import-Counter -Path ProcessorData.csv -ListSet *IdentifyImport 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 $endIdentifyImport 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]IdentifyGet a summary of counter data from a file
Import-Counter "D:\Samples\Memory.blg" -SummaryIdentifyUpdate 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.blgIdentifyImport performance log data from multiple files and then save it
$counters = "D:\test\pdata.blg", "D:\samples\netlog.blg" | Import-CounterIdentifyIts page in the reference: Import-Counter.
Parameters
-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.