From this, I tweaked the script to make it a bit more useful for my project. I added a command-line variable so that I don't have to type in each name via a read-host. Then I converted the output format so that I would return a variable instead.
<# .SYNOPSIS Report-RAM.PS1 - Returns a DIMM report on the remote server. .DESCRIPTION Uses WMI to read PhysicalMemory and PhysicalMemoryArray varia .PARAMETERName of the remote maching you want to query. Use "." for local PC. .EXAMPLE .\Report-Ram.ps1 -ComputerName "." ComputerName : . AvailableDIMMCount : 4 Slots : {@{Capacity=4294967296; DeviceLocator=DIMM3}, @{Capacity=4294967296; DeviceLocator=DIMM1}} InstalledCapacity : 8589934592 InstalledCapacityGB : 8 InstalledDIMMCount : 2 .REFERENCE http://www.powershellpro.com/dimm-witt/200/ #> [CmdLetBinding()] param( [parameter(Mandatory=$true)] [String]$ComputerName ) $RAMSummary = New-Object -TypeName PSObject $RAMSummary | Add-Member -Name "ComputerName" -MemberType NoteProperty -Value $ComputerName $colSlots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2" -computerName $ComputerName $colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2" -computerName $ComputerName $TotalSlots = 0 Foreach ($objSlot In $colSlots){ #"Total Number of DIMM Slots: " + $objSlot.MemoryDevices $TotalSlots += $objSlot.MemoryDevices } $RAMSummary | Add-Member -Name "AvailableDIMMCount" -MemberType NoteProperty -Value $TotalSlots $InstalledRam = 0 $ChipCount = 0 $Slots = @() Foreach ($objRAM In $colRAM) { $Slot = New-Object -TypeName PSObject $Slot | Add-Member -Name "Capacity" -MemberType NoteProperty -Value $objRAM.Capacity $Slot | Add-Member -Name "DeviceLocator" -MemberType NoteProperty -Value $objRAM.DeviceLocator $Slots += $Slot #"Memory Installed: " + $objRAM.DeviceLocator $InstalledRam += $objRAM.Capacity $ChipCount += 1 #"Memory Size: " + ($objRAM.Capacity / 1GB) + " GB" } $RAMSummary | Add-Member -Name "Slots" -MemberType NoteProperty -Value $Slots $RAMSummary | Add-Member -Name "InstalledCapacity" -MemberType NoteProperty -Value $InstalledRam $RAMSummary | Add-Member -Name "InstalledCapacityGB" -MemberType NoteProperty -Value ($InstalledRam /1GB) $RAMSummary | Add-Member -Name "InstalledDIMMCount" -MemberType NoteProperty -Value $ChipCount Return $RAMSummary
For my purposes, I ran it against all my mailbox servers. So I did something like:
$RamReport = get-mailboxserver | %{.\report-RAM.ps1 $_.Name} $RamReport | ?{$_.InstalledCapacity -lt 80GB} | Select ComputerName,InstalledCapacityGB | export-CSV "c:\report.csv"
No comments:
Post a Comment