Hi,
Wrote a script which will give me CPU, MEM, DISK usage. But, I am not able to get weekly report of this. Can someone help me, what I am missing here:
$ServerListFile = “C:\Users\venkatak\Desktop\Test\ServerList.txt”
$ServerList = Get-Content $ServerListFile -ErrorAction SilentlyContinue
$Result = @()
ForEach($computername in $ServerList)
{
$AVGProc = Get-WmiObject -computername $computername win32_processor |
Measure-Object -property LoadPercentage -Average | Select Average
$OS = gwmi -Class win32_operatingsystem -computername $computername |
Select-Object @{Name = “MemoryUsage”; Expression = {“{0:N2}” -f ((($.TotalVisibleMemorySize - $.FreePhysicalMemory)*100)/ $.TotalVisibleMemorySize) }}
$vol = Get-WmiObject -Class win32_Volume -ComputerName $computername -Filter “DriveLetter = ‘C:’” |
Select-object @{Name = “C PercentFree”; Expression = {“{0:N2}” -f (($.FreeSpace / $_.Capacity)*100) } }
$result += [PSCustomObject] @{
ServerName = “$computername”
CPULoad = “$($AVGProc.Average)%”
MemLoad = “$($OS.MemoryUsage)%”
CDrive = “$($vol.‘C PercentFree’)%”
}
$Outputreport = " Server Health Report
Server Health Report
Server Name
Avrg.CPU Utilization
Memory Utilization
C Drive Utilizatoin"
Foreach($Entry in $Result)
{
if(($Entry.CpuLoad) -or ($Entry.memload) -ge "80")
{
$Outputreport += ""
}
else
{
$Outputreport += ""
}
$Outputreport += "$($Entry.Servername)$($Entry.CPULoad)$($Entry.MemLoad)$($Entry.Cdrive)"
}
$Outputreport += ""
}
$Outputreport | out-file C:\Users\venkatak\Desktop\Test\Test.htm
-Kalyan