get-wmiobject -query“从Win32_LogicalMemoryConfiguration中选择TotalPhysicalMemory” - 计算机COMPUTERNAME>> output.csv
get-wmiobject -query“从Win32_LogicalMemoryConfiguration中选择TotalPageFileSpace” - 计算机COMPUTERNAME>> output.csv
我正在尝试使用输出完成此脚本:
Computer Physical Memory Virtual Memory
server1 4096mb 8000mb
server2 2048mb 4000mb
答案 0 :(得分:1)
有什么东西阻止你做这样的事吗?
gwmi -query "Select TotalPhysicalMemory,TotalPageFileSpace from Win32_LogicalMemoryConfiguration" -computer $COMPUTERNAME |
select @{Name='Computer', Expression=$COMPUTERNAME},
@{Name='Physical Memory', Expression=$_.TotalPhysicalMemory},
@{Name='Virtual Memory', Expression=$_.TotalPageFileSize} |
Export-Csv
(未经测试,因为Get-WmiOject在这里不知道Win32_LogicalMemoryConfiguration类。但可能会有效。)
答案 1 :(得分:0)
Win32_LogicalMemoryConfiguration似乎已过时。我认为这个功能可以获得你想要的信息:
function Get-MemoryInfo
{
Process
{
Get-WmiObject Win32_OperatingSystem -ComputerName $_ |
% {
New-Object PSObject |
Add-Member NoteProperty Computer $_.CSName -PassThru |
Add-Member NoteProperty VirtualMemoryMB ([int]($_.TotalVirtualMemorySize / 1KB)) -PassThru
} |
% {
$cs = Get-WmiObject Win32_ComputerSystem -ComputerName $_.Computer
$_ | Add-Member NoteProperty PhysicalMemoryMB ([int]($cs.TotalPhysicalMemory / 1MB)) -PassThru
}
}
}
您可以将计算机列表传输到Get-MemoryInfo中。如果需要csv文件,则将输出通过管道传输到Export-Csv。