Posts

Showing posts from March, 2018

Monitoring your servers using powershell

There were sometimes in my work life were I had to do things my own way and there was no help from anyone.... I created this script 2 years ago to monitor all my windows servers. This script is divided into PowerShell functions. Each function can monitor a certain resource in your server. Take a look: ### Script starts here Function Ping-server { param([string]$ServerName) $pingsrv = Test-Connection -ComputerName $ServerName if ($pingsrv){Write-Host "server " $ServerName "is reachable.."}else {Write-Host "server " $ServerName " is not reachable!!!!, please chack..."} } function get-volsize { param([string]$ServerName) $getvols = Get-WmiObject -Class CIM_LogicalDisk -ComputerName $ServerName  | where {$_.DriveType -eq "3"} foreach ($rr in $getvols) { $devid = $rr.DeviceID $VolName = $rr.VolumeName $DriveFullsp = $rr.Size $DriveFresp = $rr.FreeSpace $UsedSpace = $DriveFullsp - $DriveFresp $PercentFree =($DriveFr