How to check server health status check using PowerShell in SharePoint

This PowerShell tutorial we will discuss, how to check server health status check in SharePoint 2013/2016 using PowerShell. This script pools server health status (CPU usage, Drive utilization, Memory utilization) for the servers.

Below are the script and steps to run the same:

  • Log in to the server and open PowerShell ISE or PowerShell with administrator rights.
  • Copy this code to the PowerShell ISE and do modify
  • Click on run button or press F5.
  • Wait till the competition of code5. You will get one .htm file to provided location open and verify the same.

Note: make sure you have created server name details on the script page.

Below are the screenshots to do:

  • Download the attached PowerShell script and save to drive.
  • Modify as we mentioned and save the same.
  • Open PowerShell with admin rights and run this command and see the result as below:
check server health status check using PowerShell in SharePoint

Check server health status check using PowerShell in SharePoint

Below is the PowerShell script to check the server health status check in SharePoint using PowerShell.

## Server Health Check
## Created by Prashant Kumar
## Date : 14 July 2016
## Email: prashant8590@outlook.com
## This scripts check the server Avrg CPU and Memory utlization along with C drive
## disk utilization and sends an email to the receipents included in the script

$ServerListFile = "E:\prashant\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 = "<HTML><TITLE> Server Health Report </TITLE>
<BODY background-color:peachpuff>
<font color =""#99000″" face=""Microsoft Tai le"">
<H2> Server Health Report </H2></font>
<Table border=1 cellpadding=0 cellspacing=0>
<TR bgcolor=gray align=center>
<TD><B>Server Name</B></TD>
<TD><B>Avrg.CPU Utilization</B></TD>
<TD><B>Memory Utilization</B></TD>
<TD><B>C Drive Utilizatoin</B></TD></TR>"

Foreach($Entry in $Result)
{
if((($Entry.CpuLoad) -or ($Entry.memload)) -ge "80")
{
$Outputreport += "<TR bgcolor=red>"
}
else
{
$Outputreport += "<TR>"
}
$Outputreport += "<TD>$($Entry.Servername)</TD><TD align=center>$($Entry.CPULoad)</TD><TD align=center>$($Entry.MemLoad)</TD><TD align=center>$($Entry.Cdrive)</TD></TR>"
}
$Outputreport += "</Table></BODY></HTML>"
}
$Outputreport | out-file E:\prashant\Test.htm

This is how to check the server health status check using PowerShell in SharePoint 2013/2016.

You may like following PowerShell SharePoint tutorials:

Tags: how to check server health in windows 2012, server health report powershell, windows server health check commands, windows server health check report using PowerShell, powershell script for server monitoring, powershell server health check sharepoint, powershell server health check sharepoint 2010, powershell server health check sharepoint 2013, powershell server health check sharepoint 2016, sharepoint health check powershell, sharepoint 2013 health check, sharepoint 2013 farm health check, sharepoint health check powershell

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>