Skip to content

Instantly share code, notes, and snippets.

@rockaut
Last active January 13, 2020 09:43
Show Gist options
  • Save rockaut/3906a3b5ad16aa4405fb616be1d5dde2 to your computer and use it in GitHub Desktop.
Save rockaut/3906a3b5ad16aa4405fb616be1d5dde2 to your computer and use it in GitHub Desktop.
param
(
[Parameter(Mandatory=$true)]
$Value
)
$key = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009'
$counters = (Get-ItemProperty -Path $key -Name Counter).Counter
$index = [array]::indexof($counters, "$Value")
if($index -lt 0) {
return $null
}
if( $Value -match "^\d+$" ) {
$result = New-Object -TypeName psobject -Property @{
"Name" = $counters[$index+1];
"Id" = $counters[$index];
}
} else {
$result = New-Object -TypeName psobject -Property @{
"Name" = $counters[$index];
"Id" = $counters[$index-1];
}
}
return $result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment