Export-Counter
성능 카운터 데이터를 로그 파일로 내보냅니다.
구문
Export-Counter
[-Path] <String>
[-FileFormat <String>]
[-MaxSize <UInt32>]
-InputObject <PerformanceCounterSampleSet[]>
[-Force]
[-Circular]
[<CommonParameters>]
Description
Export-Counter cmdlet은 성능 카운터 데이터(PerformanceCounterSampleSet 개체)를 내보내서 이진 성능 로그(.blg), 쉼표로 구분된 값(.csv) 또는 탭으로 구분된 값(.tsv) 형식의 파일을 기록합니다. 이 cmdlet을 사용하여 성능 카운터 데이터를 기록할 수 있습니다.
Export-Counter cmdlet은 Get-Counter 및 Import-Counter cmdlet에서 반환되는 데이터를 내보내도록 설계되었습니다.
이 cmdlet은 Windows 7, Windows Server 2008 R2 이상 버전의 Windows에서만 실행됩니다.
예제
예제 1: 카운터 데이터를 파일로 내보내기
PS C:\> Get-Counter "\Processor(*)\% Processor Time" | Export-Counter -Path $home\Counters.blg
이 명령은 카운터 데이터를 BLG 파일로 내보냅니다.
이 명령은 Get-Counter cmdlet을 사용하여 프로세서 시간 데이터를 수집합니다. 파이프라인 연산자(|)를 사용하여 데이터를 Export-Counter cmdlet으로 보냅니다. Export-Counter 명령은 Path 변수를 사용하여 출력 파일을 지정합니다.
데이터 집합이 매우 클 수 있으므로 이 명령은 파이프라인을 통해 Export-Counter 데이터를 보냅니다. 데이터가 변수에 저장된 경우 명령은 불균형한 양의 메모리를 사용할 수 있습니다.
예제 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 the **Export-Counter** cmdlet to create a circular log that wraps at 1 GB.
PS C:\> Import-Counter Threads.csv | Export-Counter -Path ThreadTest.blg -Circular -MaxSize $1GBinBytes
다음은 CSV 파일을 카운터 데이터 BLG 형식으로 변환하는 예제입니다.
예제 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
이 예제에서는 원격 컴퓨터에서 성능 카운터 데이터를 가져와서 원격 컴퓨터의 파일에 데이터를 저장하는 방법을 보여 줍니다.
예제 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
이 예제에서는 Import-Counter 및 Export-Counter cmdlet을 사용하여 기존 데이터를 다시 기록하는 방법을 보여 줍니다.
매개 변수
-Circular
출력 파일이 FIFO(First in, first out) 형식의 순환 로그임을 나타냅니다. 이 매개 변수를 포함하면 MaxSize 매개 변수가 필요합니다.
형식: | SwitchParameter |
Position: | Named |
Default value: | False |
필수: | False |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-FileFormat
출력 로그 파일의 출력 형식을 지정합니다.
이 매개 변수에 허용되는 값은 다음과 같습니다.
- CSV
- TSV
- BLG
기본값은 BLG입니다.
형식: | String |
Position: | Named |
Default value: | BLG |
필수: | False |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-Force
Path 매개 변수로 지정된 위치에 있는 경우 기존 파일을 덮어쓰고 바꿉니다.
형식: | SwitchParameter |
Position: | Named |
Default value: | False |
필수: | False |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-InputObject
내보낼 카운터 데이터를 배열로 지정합니다. Get-Counter 또는 Import-Counter cmdlet과 같이 데이터를 가져오는 명령이나 데이터가 포함된 변수를 입력합니다.
형식: | PerformanceCounterSampleSet[] |
Position: | Named |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | True |
와일드카드 문자 허용: | False |
-MaxSize
출력 파일의 최대 크기를 지정합니다.
Circular 매개 변수를 지정한 경우 로그 파일이 지정된 최대 크기에 도달하면 최신 항목이 추가되면 가장 오래된 항목이 삭제됩니다. Circular 매개 변수를 지정하지 않으면 로그 파일이 지정된 최대 크기에 도달하면 새 데이터가 추가되지 않고 cmdlet이 종료되지 않는 오류를 생성합니다.
형식: | UInt32 |
Position: | Named |
Default value: | None |
필수: | False |
파이프라인 입력 허용: | False |
와일드카드 문자 허용: | False |
-Path
출력 파일의 경로 및 파일 이름을 지정합니다. 로컬 컴퓨터의 상대 또는 절대 경로 또는 원격 컴퓨터에 대한 UNC(Uniform Naming Convention) 경로를 입력합니다(예: \\Computer\Share\file.blg). 이 매개 변수는 필수입니다.
파일 형식은 경로의 파일 이름 확장명 대신 FileFormat 매개 변수의 값에 따라 결정됩니다.
형식: | String |
별칭: | PSPath |
Position: | 0 |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | True |
와일드카드 문자 허용: | False |
입력
성능 카운터 데이터를
출력
None
참고
로그 파일 생성기는 모든 입력 개체의 카운터 경로가 동일하고 개체가 오름차순으로 정렬되어야 합니다.
첫 번째 입력 개체의 카운터 형식 및 경로는 로그 파일에 기록된 속성을 결정합니다. 다른 입력 개체에 기록된 속성에 대한 값이 없으면 속성 필드가 비어 있습니다. 개체에 기록되지 않은 속성 값이 있는 경우 추가 속성 값은 무시됩니다.
성능 모니터가 Export-Counter 생성할
모든 로그를 읽지 못할 수 있습니다. 예를 들어 성능 모니터를 사용하려면 모든 개체의 경로가 동일하고 모든 개체가 동일한 시간 간격으로 구분되어야 합니다. Import-Counter cmdlet에는 ComputerName 매개 변수가 없습니다. 그러나 컴퓨터가 원격 Windows PowerShell Windows PowerShell용으로 구성된 경우 Invoke-Command cmdlet을 사용하여 원격 컴퓨터에서 Import-Counter 명령을 실행할 수 있습니다.