molotova
31-05-2015, 12:25
Суть такая: нужно получить состояние системного кэша из-под ограниченной учетки. Заранее спасибо!
greg zakharov
31-05-2015, 14:17
Было дело, такая же задача подворачивалась.function Get-SystemFileCache {
$SYSTEM_INFO = ($o = [Object].Assembly.GetType(
'Microsoft.Win32.Win32Native'
)).GetNestedType(
'SYSTEM_INFO', [Reflection.BindingFlags]36
).InvokeMember(
$null, [Reflection.BindingFlags]512, $null, $null, $null
)
$o.GetMethod(
'GetSystemInfo', [Reflection.BindingFlags]40
).Invoke($null, ($si = [Object[]]@($SYSTEM_INFO)))
$PageSize = $si[0].GetType().GetField(
'dwPageSize', [Reflection.BindingFlags]36
).GetValue($si[0])
$ptr = [Runtime.InteropServices.Marshal]::AllocHGlobal(36)
if ([Regex].Assembly.GetType(
'Microsoft.Win32.NativeMethods'
).GetMethod(
'NtQuerySystemInformation'
).Invoke($null, @(21, $ptr, 36, 0)) -eq 0) {
New-Object PSObject -Property @{
CurrentSize = [Runtime.InteropServices.Marshal]::ReadInt32($ptr) / 1KB
PeakSize = [Runtime.InteropServices.Marshal]::ReadInt32($ptr, 4) / 1KB
MaximumWS = [Runtime.InteropServices.Marshal]::ReadInt32($ptr, 16) * $PageSize / 1KB
MinimumWS = [Runtime.InteropServices.Marshal]::ReadInt32($ptr, 12) * $PageSize / 1KB
} | Format-List
}
[Runtime.InteropServices.Marshal]::FreeHGlobal($ptr)
}
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.