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

Server Health Check sharepoint
InfoPath alternatives for form designing SharePoint

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. Login 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 script page.

Also read:
– How to cancel all workflows from one List in SharePoint using PowerShell?

– SharePoint 2013 central admin site error method upgrade in type microsoft.sharepoint.workflowservices.workflow services

– How to do an IISReset in all the servers in a SharePoint Farm?

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.

Similar SharePoint 2013 Tutorials


Leave a Reply