Automating server checks

Welcome Forums General PowerShell Q&A Automating server checks

This topic contains 5 replies, has 2 voices, and was last updated by

3 years, 10 months ago.

  • Author
  • #25029

    Points: 0
    Rank: Member

    Hi Guys,

    We have a task we have to do everyday on all our clients servers we have to check the following things

    Internet connection
    Disk free space on all disks
    Exchange Store Status
    Exchange Mail Queues
    Check the backup job status of either Widnows Backup/Backup Exec/Altatro Backup
    Check if latest windows updates are install or if there are any updates pending
    Make sure Trend AntiVirus is running.

    I managed to get the disk space check and the internet connection test working
    To test the internet connection i will just use

    Test-Connection | Export-Csv 'C:\tmp\internettest.csv'

    and check the disk free space

    #Create Array and set AlertState to 0

    $AlertDisks = @()
    $AlertState = 0

    #WMI call and custom object creation

    $Disks = Get-WmiObject -ComputerName localhost -Class win32_logicaldisk | Where-Object {$_.MediaType -match "12"} |
    select PSComputerName, DeviceID, VolumeName, @{Name='Size (GB)' ;Expression={"{0:n2}" -f ($_.size/1gb)}}, @{Name='FreeSpace (GB)' ;Expression={"{0:n2}" -f ($_.FreeSpace/1gb)}}, @{Name='PercentFree' ;Expression={"{0:n2}" -f ($_.freespace/$_.size*100)}}

    Write-Output $Disks

    If anyone has any ideas to check the other tasks or can help add all this in one script that would be awesome.

    As I continue getting ways to check the other tasks I will add it to the topic

  • #25030

    Points: 0
    Rank: Member

    I found this online to test the internet connection

    #Start testing the connection and continue until the connection is good.
    While (!(Test-Connection -computer -count 1 -quiet)) {
    Write-Host -ForegroundColor Red -NoNewline "Connection down..."
    Start-Sleep -Seconds 2
    #Connection is good
    Write-Host -ForegroundColor Green "$(Get-Date): Connection up!"

  • #25045

    Points: 637
    Helping Hand
    Rank: Major Contributor

    You're not asking for anything to earth shattering, I'm pretty sure you can find answers to everything with a couple of Internet searches. As far as reporting, you could generate an HTML email by using ConvertTo-HTML -Fragment and Send-MailMessage -BodyAsHTML

    There are also some free e-books on this site for HTML Reporting that can get you a final report.

  • #25085

    Points: 0
    Rank: Member

    I'm not just trying to check just the exchange server but help on compiling all of the reporting in one.
    Looks like I misunderstood the community aspect of the forum or it might be one user.

  • #25124

    Points: 637
    Helping Hand
    Rank: Major Contributor

    All I'm saying is you want a lot of information. The first step is getting the data you want whether it be in separate or a single script. Almost everything you want is available on the internet, including creating reports with Powershell. If you need help with a specific thing not working, I'm sure the community would be more than happy to assist you. Like how do I convert Test-Connection to a Boolean value (True\False):

    function Get-ComputerInfo {
        $os = Get-CimInstance -ClassName Win32_OperatingSystem | Select Caption
        $computer = Get-CimInstance -ClassName Win32_ComputerSystem | Select Name, Manufacturer, @{Label="OperatingSystem"; Expression={$os.Caption}}
    function Test-InternetConnected {
        New-Object -TypeName PSObject -Property @{"InternetConnected" = $(Test-Connection -Computername -Count 2 -Quiet);"DateTime"=(Get-Date);}
    $htmlFrag1 = Get-ComputerInfo | ConvertTo-HTML -Fragment -As Table -PreContent "Computer Information:"
    $htmlFrag2 = Test-InternetConnected | ConvertTo-HTML -Fragment -As Table  -PreContent "Internet Status:"
    ConvertTo-HTML -Title "My Server Report" -Body "$htmlFrag1 $htmlFrag2" | Out-File C:\Temp\ServerReport.html
    Invoke-Item C:\Temp\ServerReport.html

    I need a report with 15 items and have 2 pieces isn't asking the community for help, it's asking them to do your research for you. I'm really not trying to be snooty or anything, but your asking for like a 500+ lines of code report and have 20 lines contributed.

    Get the data you need (in a single or multiple script)
    Modularize the code (create functions)
    Convert it to a HTML report
    Clean up report with CSS

  • #25138

    Points: 0
    Rank: Member

    I get what you're saying, and that does make sense.
    I was hoping someone has already done some kind of server check and would be able to help me.
    But your update makes loads of sense, the community is not to create a whole script for you but to help you if your script is not working.

The topic ‘Automating server checks’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort