PowerShell Logo Small

Export-Counter



This is the built-in help made by Microsoft for the command 'Export-Counter', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

The Export-Counter cmdlet takes PerformanceCounterSampleSet objects and exports them as counter log files.

SYNTAX


Export-Counter [-Path] <String> [-Circular [<SwitchParameter>]] [-FileFormat <String>] [-Force [<SwitchParameter>]] [-MaxSize <UInt32>]
-InputObject <PerformanceCounterSampleSet[]> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Export-Counter cmdlet exports performance counter data (PerformanceCounterSampleSet objects) to log files in binary performance log
(.blg), comma-separated value (.csv), or tab-separated value (.tsv) format. You can use this cmdlet to log or relog performance counter data.


Export-Counter is designed to export data that is returned by the Get-Counter and Import-Counter cmdlets.


Note: Export-Counter runs only on Windows 7, Windows Server 2008 R2, and later versions of Windows.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=138337
Get-Counter
Import-Counter

REMARKS

<

Examples


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

PS C:\> Get-Counter "\Processor(*)\% Processor Time" | Export-Counter -Path $home\Counters.blg



This command exports counter data to a .blg file.

The command uses the Get-Counter cmdlet to collect processor time data. It uses a pipeline operator (|) to send the data to the Export-Counter
cmdlet. The Export-Counter command uses the Path variable to specify the output file.

Because the data set might be very large, this command sends the data to Export-Counter through the pipeline. If the data were saved in a
variable, the command might use a disproportionate amount of memory.




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

The first command uses the built-in Windows PowerShell conversion feature to store the value of 1 gigabyte (GB) in bytes in the $1GBInBytes
variable. When you type a value followed by K (kilobyte), MB (megabyte), or GB, Windows PowerShell returns the value in bytes.
PS C:\> $1GBInBytes = 1GB

The second command uses the Import-Counter cmdlet to import performance counter data from the Threads.csv file. The example presumes that this
file was previously exported by using the Export-Counter cmdlet. A pipeline operator (|) sends the imported data to the Export-Counter cmdlet.
The command uses the Path parameter to specify the location of the output file. It uses the Circular and MaxSize parameters to direct
Export-Counter to create a circular log that wraps at 1 GB.
PS C:\> Import-Counter Threads.csv | Export-Counter -Path ThreadTest.blg -Circular -MaxSize $1GBinBytes



These commands convert a CSV file to a counter data BLG format.




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

The first command uses the Get-Counter cmdlet to collect working set counter data from Server01, a remote computer. The command saves the data
in the $c variable.
PS C:\> $c = Get-Counter -ComputerName Server01 -Counter "\Process(*)\Working Set - Private" -MaxSamples 20

The second command uses a pipeline operator (|) to send the data in $c to the Export-Counter cmdlet, which saves it in the Workingset.blg file
in the Perf share of the Server01 computer.
PS C:\> $c | Export-Counter -Path \\Server01\Perf\WorkingSet.blg



This example shows how to get performance counter data from a remote computer and save the data in a file on the remote computer.




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

The first command uses the Import-Counter cmdlet to import performance counter data from the DiskSpace.blg log. It saves the data in the $All
variable. This file contains samples of the "LogicalDisk\% Free Space" counter on more than 200 remote computers in the enterprise.
PS C:\> $All = Import-Counter DiskSpace.blg

The second command uses the CounterSamples property of the sample set object in $All and the Where-Object cmdlet (alias = "where") to select
objects with CookedValues of less than 15 (percent). The command saves the results in the $LowSpace variable.
PS C:\> $LowSpace = $All.CounterSamples | where {$_.CookedValues -lt 15}

The third command uses a pipeline operator (|) to send the data in the $LowSpace variable to the Export-Counter cmdlet. The command uses the
Path parameter to indicate that the selected data should be logged in the LowDiskSpace.blg file.
PS C:\> $LowSpace | Export-Counter -Path LowDiskSpace.blg



This example shows how to use the Import-Counter and Export-Counter cmdlets to re-log existing data.