Quick script to collection permon data via powershell. This will continuously spit out just the physical disk stats to a csv file (max 1GB) every 10 seconds. Use at your own risk. Barely tested.
function Get-PhysicalDisk{
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$false)]
$ComputerName,
[Parameter(Mandatory=$true,ValueFromPipeline=$false)]
$FileName
)
$outputs = @();
$1GB = 1GB
if(Test-Path $FileName){
Remove-Item $FileName -Force
}
$physDiskCounters = Get-Counter -ComputerName $ComputerName -ListSet PhysicalDisk
Get-Counter -ComputerName $ComputerName -Counter $physDiskCounters.Paths -Continuous -SampleInterval 10 | Export-Counter -Path $FileName -FileFormat "CSV" -Circular -MaxSize $1GB -Force
}
I usually start this in a job on multiple servers via the Start-Job cmdlet so it will run in the background like so:
gc -Path C:\Servers.txt | %{
$srvName = $_
$fileName = "c:\Test\$($srvName)_PhysicalDisk.csv"
$job = Start-Job {
param(
$compName,
$fName
)
. "C:\PathToGetPhysicalDiskFile\Get-PhysicalDisk.ps1"
Get-PhysicalDisk $compName $fName
} -ArgumentList @($srvName, $fileName)
}
Leave a comment