我无法使用 powershell 从 Windows 管理对象获取物理内存信息。这些列是在 excel 电子表格中生成的,但在 Winmgmt 对象中没有找到数据。
$strComputer =“。”
$Excel = 新对象 -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(1,2) = “银行标签”
$Sheet.Cells.Item(1,3) = “容量”
$Sheet.Cells.Item(1,4) = “标题”
$Sheet.Cells.Item(1,5) = “数据宽度”
$Sheet.Cells.Item(1,6) = “描述”
$Sheet.Cells.Item(1,7) = “设备定位器”
$Sheet.Cells.Item(1,8) = "外形尺寸"
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 8
$WorkBook.Font.ColorIndex = 11
$WorkBook.Font.Bold = $True
$intRow = 2
$colItems = get-wmiobject -class “Win32_PhysicalMemory” -namespace “root CIMV2” -computername $strComputer
foreach ($colItems 中的 $objItem) {
$Sheet.Cells.Item($intRow,1)= $strComputer
$Sheet.Cells.Item($intRow,2) = $objItem.BankLabel
$Sheet.Cells.Item($intRow,3) = $objItem.Capacity
$Sheet.Cells.Item($intRow,4) = $objItem.Caption
$Sheet.Cells.Item($intRow,5) = $objItem.DataWidth
$Sheet.Cells.Item($intRow,6) = $objItem.Description
$Sheet.Cells.Item($intRow,7) = $objItem.DeviceLocator
$Sheet.Cells.Item($intRow,8) = $objItem.FormFactor
$intRow = $intRow + 1
}
$WorkBook.EntireColumn.AutoFit()
清除