Memory, IRQ and devices
Posted by: Richard Siddaway
One of our most valuable system resources is memory. Back in the day we also used to worry about IRQs as we only had 16 but modern Windows gets round this for us.
If you want to know what memory is being used by which device then try this. We also get IRQ as a bonus
$source = @"
public class sysirqram {
public string Memory { get; set;}
public string Device { get; set;}
public string Status { get; set;}
public long IRQ { get; set;}
}
"@
Add-Type $source -Language CSharpVersion3
$data = @()
Get-WmiObject Win32_DeviceMemoryAddress | foreach {
$name = $_.Name
$query = "ASSOCIATORS OF `
{Win32_DeviceMemoryAddress.StartingAddress=’$($_.StartingAddress)’} `
WHERE RESULTCLASS = Win32_PnPEntity"
Get-WmiObject -Query $query | foreach {
$qirq = "ASSOCIATORS OF {Win32_PnPEntity.DeviceID=’$($_.PNPDeviceID)’} `
WHERE RESULTCLASS = Win32_IRQResource"
$irqs = Get-WmiObject -Query $qirq | select IRQNumber -Unique
$myobject = New-Object -TypeName sysirqram -Property @{
Memory= $name;
Device = $_.Name;
Status = $_.Status;
IRQ = $irqs.IRQNumber
}
$data += $myobject
}
}
$data | Format-Table -AutoSize
Define a new class and create it using Add-Type. We can then start with the Win32_Devicememory class to discover what memory is being used. Thsi can be associated with the Win32_PNPEntity class to get the device which we then associate with Win32_IRQResource to get the IRQ.
Not the simplest of WMI scripts but its logical when you pick it apart




