Import performance counter log files (.blg, .csv, .tsv) and create the objects that represent each counter sample in the log.
Syntax Import-Counter [-Path] string[] [-Counter string[]] [-EndTime DateTime] [-MaxSamples Int64] [-StartTime DateTime] [CommonParameters] Import-Counter [-Path] string[] -ListSet <string[]> [CommonParameters] Import-Counter [-Path] string[] -Summary [CommonParameters] Key: -Counter string[] Import data only for the specified 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. Notice that the ComputerName value is required in the path, even on the local computer. "\\ComputerName\CounterSet(Instance)\CounterName" For example: "\\Server64\Processor(2)\% User Time" "\Processor(*)\% Processor Time -EndTime DateTime Imports only counter data with a timestamp <= DateTime Enter a DateTime object, such as one created by Get-Date By default, Import-Counter imports all counter data in the files specified by -Path. -ListSet string[] Get 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 *" -MaxSamples Int64 The maximum number of samples of each counter to import. By default, all counter data will be imported from the files specified by -Path. -Path string[] 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 was exported with Export-Counter. Specify one .csv or .tsv file, or multiple .blg files (up to 32) in each command. The file path strings (in quotation marks) can also be piped to Import-Counter. -StartTime DateTime Import only counter data with a timestamp >= DateTime Enter a DateTime object, such as one created by Get-Date. By default, all counter data will be imported from the files specified by -Path. -Summary Get a summary of the imported data, instead of getting individual counter data samples. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
When using .blg files, you can import up to 32 different files in each command. The data being imported can be filtered.
Examples
Import all the counter data from services.csv file into the $svc variable.:
PS C:> $svc = import-counter -path C:\services.csv
Import only the Processor(_total)\Interrupts\sec counter data into the $i variable:
PS C:> $i = import-counter -path C:\ProcessorData.blg -counter "\\SERVER64\Processor(_Total)\Interrupts/sec"
Select data from a performance counter log file (.blg) and then export to a .csv file.:
PS C:> $mycpu = import-counter C:\CPUdata.blg
PS C:> $mycpu[0].countersamples | format-table path
PS C:> $CounterPaths = $data[0].countersamples | where {$_.path -like "*interrupts/sec"} | foreach {$_.path}
PS C:> $CounterPaths
PS C:> $i = import-counter -path .\CPUdata.blg -counter $CounterPaths
PS C:> $i | export-counter -path .\interrupts.csv -format CSV
Display all the counter paths in a group of imported counter sets.:
PS C:> import-counter -path cpudata.csv -listset *
PS C:> import-counter -path cpudata.csv -listset * | foreach {$_.paths}
List the time stamps of all of the data in the disc.blg file:
PS C:> import-counter -path .\disk.blg | format-table timestamp
Import only counter data from disc.blg that has a time stamp between a given start / end:
PS C:> $start = [datetime]"7/12/2010 3:47:00 PM"
PS C:> $end = [datetime]"7/12/2010 3:47:59 PM"
PS C:> $timedata = import-counter -path disk.blg -starttime $start -endtime $end
Summarise the counter data in Memory.blg:
PS C:> import-counter D:\memory.blg -summary
Update a performance counter log file with fresh data:
PS C:> $counters = import-counter c:\olddata.blg -ListSet * | foreach {$_.PathsWithInstances}
PS C:> get-counter -counter $counters -maxSamples 20 | export-counter c:\newdata.blg
Import two performance logs and save the data in a variable. Then pipe this to Import-Counter:
PS C:> $counters = "d:\pdata.blg", "d:\netlog.blg" | import-counter
“Actors should be overheard, not listened to, and the audience is 50 percent of the performance” ~ Shirley Booth
Related PowerShell Cmdlets:
Get-Counter - Get performance counter data.
Export-Counter - Export Performance Counter data to log files.