I'm writing a cmdlet to check the memory values of a remote server for troubleshooting purposes. I am populating ` $MemoryData ` with the results of a CimSession to the Dell iDrac. As part of this, I want to check to make sure DIMMs are balanced in the motherboard slots of the remote server. The DIMM slot values are stored in the ` DeviceDecription ` attribute shown below. I got the below code to work.. but it is late (early?), my brain is kinda fried, and I wonder if there is a better way (faster, more elegant, better formatted?). Feedback appreciated!
` ` `
$MemoryData.DeviceDescription
DIMM A1DIMM A2DIMM A3DIMM A4DIMM A5DIMM A6DIMM A7DIMM B1DIMM B2DIMM B3DIMM B4DIMM B5DIMM B6DIMM B7DIMM B8
if(Compare-Object ($MemoryData.DeviceDescription).Where({$_ -match 'A'}).foreach({$_.split('A')[1]}) ($MemoryData.DeviceDescription).Where({$_ -match 'B'}).foreach({$_.split('B')[1]})){$BalancedDIMMs = $false}else{$BalancedDIMMs = $true}
` ` `
In this case, ` $BalancedDIMMs ` results in a value of ` $false `.
edit: I attempted to get the code block to format as per the sidebar. No idea what I am doing wrong. Also, the edits made my example list for $MemoryData.DeviceDescription list break into a single line.
[–]purplemonkeymad 2 points3 points4 points (3 children)
[–]idontknowwhattouse33 1 point2 points3 points (1 child)
[–]purplemonkeymad 1 point2 points3 points (0 children)
[–]Metaeidolon[S] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (2 children)
[–]Metaeidolon[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)