你能帮我把这三个脚本组合成这样的格式吗
ComputerName CPUUsageAverage MemoryUsage C PercentFree
xxx 12 50% 30%
我执行此操作的方式是:
Get-content '.\servers.txt' | Get-CPUusageAverage
以下是脚本:
中央处理器
Function Get-CPUusageAverage
{
$input|Foreach-Object{Get-WmiObject -computername $_ win32_processor | Measure-Object -property LoadPercentage -Average | Select Average}
}
记忆
Function get-MemoryUsage
{
$input|Foreach-Object{
gwmi -Class win32_operatingsystem -computername $_ |
Select-Object @{Name = "MemoryUsage"; Expression = { “{0:N2}” -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize) }
}
}
}
C 百分比免费
Function get-CPercentFree
{
$input|ForEach-Object{
Get-WmiObject -Class win32_Volume -ComputerName $_ -Filter "DriveLetter = 'C:'" |
Select-object @{Name = "C PercentFree"; Expression = { “{0:N2}” -f (($_.FreeSpace / $_.Capacity)*100) } }
}
}