Tag Archives: PoSH

Server Monitoring using Powershell and DbaTools

script it…walk away.

I’m sure by now most of you have discovered dbatools, a wonderful library of PowerShell functions that make life as a  DBA so much better.   It’s a fantastic community full of people willing to help with minimal flaming and the library itself is frequently updated.

Initially I wanted to jump on the contribution train but IRL I have jobs to consider so instaed I took more of a end user role, working on familiarizing myself  with PowerShell in order to tap into the power of dbatools.  After writing some DBA specific utilities I started looking at the bigger picture of what I could do across the infrastructure with PowerShell.

Continue reading

Database Ping and Database Status

01_Vault_101_Citizenship_Award

Pipboy level utility!

I needed something that would alert me if a database server was unreachable by the network, as well as watching for the status of all databases.

I was able to come up with the solution in Powershell.  The script will take in a list of servers, and first ping the server.  If the server fails to respond to the ping an email is generated and sent out.  If the database server is reachable then the script will look at the status of each database and generate for each one that is offline.
After you have the script working, you can then schedule it in windows task scheduler and pray it only fires off once in awhile if ever.
Todo:  This works fine except one issue.  If you have this setup to email and you use some insane checking interval like every minute, expect an email fired off every minute when during an outage.  A future improvement would be to set this up to utilize a flag that is configurable for how many times the email will be sent.