Just save it as a .PS1 file and when you run it you will be asked for the name of the machine you wish to query. If you wish to query your own PC just enter "localhost" as the name.
$strComputer = Read-Host "Enter Computer Name"
$colSlots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2" `
-computerName $strComputer
$colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2" `
-computerName $strComputer
Foreach ($objSlot In $colSlots){
"Total Number of DIMM Slots: " + $objSlot.MemoryDevices
}
Foreach ($objRAM In $colRAM) {
"Memory Installed: " + $objRAM.DeviceLocator
"Memory Size: " + ($objRAM.Capacity / 1GB) + " GB"
}
No comments:
Post a Comment