How to check server health status check in SharePoint using PowerShell?

Server Health Check sharepoint

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

Here we will discuss how to check server health status check in SharePoint 2013 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:
1. Log in to the server and open PowerShell ISE or PowerShell with administrator rights.
2. Copy this code to the PowerShell ISE and do modify
3. Click on run button or press F5.
4. Wait till 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.



Also, read some Microsoft Azure tutorials

Below are the screen shots to do:
1. Download attached PowerShell script and save to drive.
2. Modify as we mentioned and save the same.
3. Open PowerShell with admin rights and run this command and see the result as below:

Server Health Check sharepoint
Server Health Check sharepoint

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

Hope this will be helpful.


You May Also like the Following SharePoint Online Tutorials:

Leave a Reply