All Projects → Darkseal → RunningLow

Darkseal / RunningLow

Licence: MIT license
Free PowerShell script to to check for low disk space on local and network drives and send e-mail alerts when it goes under a user-defined quota.

Programming Languages

powershell
5483 projects

Projects that are alternatives of or similar to RunningLow

PowerShell-WindowsAdmin
A collection of scripts I've created over the years to administer things.
Stars: ✭ 35 (+105.88%)
Mutual labels:  windows-server, powershell-script
Win10 Initial Setup Script
PowerShell script for automation of routine tasks done after fresh installations of Windows 10 / Server 2016 / Server 2019
Stars: ✭ 4,494 (+26335.29%)
Mutual labels:  windows-server-2016, windows-server-2019
packer-vsphere-iso-windows
Create Packer Templates for Windows Server on VMware vSphere (and vCenter)
Stars: ✭ 73 (+329.41%)
Mutual labels:  windows-server-2016, windows-server-2019
rackshift
RackShift 是开源的裸金属服务器管理平台,功能覆盖裸金属服务器的发现、带外管理、RAID 配置、固件更新、操作系统安装等。
Stars: ✭ 467 (+2647.06%)
Mutual labels:  windows-server
SQLPowerDoc
Hopefully an up to date fork of SQL Power Doc. Newer PS versions and .NET levels. Maybe too ambitious. This repository was cloned from kendalvandyke, the original author of SQLPowerDoc. Codeplex is currently in the process of shutting down. I cloned this project (and its wiki) with the intention of preserving a wonderful tool that I recently dis…
Stars: ✭ 19 (+11.76%)
Mutual labels:  powershell-script
LazyTS
PowerShell Script (GUI) to manage Terminal Sessions
Stars: ✭ 85 (+400%)
Mutual labels:  powershell-script
Play-Notes
A simple Powershell function that lets you write/play songs in musical notation using the Beep() function in windows.
Stars: ✭ 17 (+0%)
Mutual labels:  powershell-script
Catharsis
Raw syscall implementations with Powershell
Stars: ✭ 18 (+5.88%)
Mutual labels:  powershell-script
NachtWal
Reinforced Mitigation Security Filter
Stars: ✭ 17 (+0%)
Mutual labels:  windows-server
PSSystemAdministrator
A PowerShell module for managing users and computers and gathering information in a Windows Active Directory environment.
Stars: ✭ 59 (+247.06%)
Mutual labels:  windows-server
AutomatedOutlookSignature
PowerShell script to automate the creation of Outlook signatures using Active Directory attributes.
Stars: ✭ 36 (+111.76%)
Mutual labels:  powershell-script
trustydns
DNS Over HTTPS proxy, server and query programs
Stars: ✭ 22 (+29.41%)
Mutual labels:  windows-server
ideal-alligator
PowerShell script to retreive wifi ESSIDs and Passwords.
Stars: ✭ 24 (+41.18%)
Mutual labels:  powershell-script
Compare-UserJS
PowerShell script for comparing user.js (or prefs.js) files.
Stars: ✭ 79 (+364.71%)
Mutual labels:  powershell-script
go-mailer
📫 Simple e-mail sender for Go Programming Language
Stars: ✭ 31 (+82.35%)
Mutual labels:  e-mail
convey
CSV processing and web related data types mutual conversion
Stars: ✭ 16 (-5.88%)
Mutual labels:  e-mail
cashier-register
Cashier Register is a simple quota feature usage tracker for Laravel Cashier subscriptions.
Stars: ✭ 93 (+447.06%)
Mutual labels:  quota
Update-AllUsersQA
Update-AllUsersQA is a PowerShell script used to change or disable the security questions and answers for local users in a Windows 10 machine.
Stars: ✭ 21 (+23.53%)
Mutual labels:  powershell-script
Windows-On-Reins
Wor is a Powershell script to harden, debloat, optimize, enhance privacy, avoid fingerprinting and improve performance on Windows 10 and 11.
Stars: ✭ 170 (+900%)
Mutual labels:  powershell-script
ucsunivention
⚫ Curso GRÁTIS SAMBA-4 UCS Univention Core Free 5.x Domain Controller Active Directory Open Source
Stars: ✭ 29 (+70.59%)
Mutual labels:  windows-server

RunningLow

Free PowerShell script to to check for low disk space and send e-mail alerts when it goes under a user-defined quota.

Introduction

RunningLow is a simple yet effective PowerShell script I coded a while ago to get to know when one of my servers is running low of disk space.

Whoever works with physical and/or virtualized Windows Servers is well aware of the importance of keeping this constantly under control: as soon as a server runs out of disk space it will be unable to fullfill a number of tasks, such as: create temporary files, store data on a database, performing system maintenance / backup / updates, create or update web sessions – assuming they are handled through I/O – and so on. Things can be even worse for those servers who host DBMS services such as MySQL and MS-SQL, as the sudden I/O unavailability could cause non-trivial damages to indexes, filesystem-based tables and data integrity.

The main purpose of RunningLow is to prevent all that: it will check one or more local and/or network drives to see if their available free space went under a certain quota, and send a customizable alert to one or more e-mail addresses if that’s the case. I know, there are A LOT of admin suites and maintenance software that could be easily configured to the same thing: even Piriform’s CCleaner PRO does that! However, if you don’t have the money, the time or the amount of system resources required to install these apps, you might find out that this lightweight alternative could be worth a shot.

Configuration

Here's a list of all RunningLow configuration settings (and their meaning). Each one of them corresponds to a command-line parameter, meaning that you can either set them using the CLI or change their default value within the script itself.

- minSize

The minimum free disk space acceptable threshold: any checked drive with less available space will raise a warning.

- hosts

If specified, will also check the disk space on the given colon-separated list of hostnames (machine names OR ip addresses) within the LAN.

Example: $hosts = "HOSTNAME1:HOSTNAME2:129.168.0.115"

IMPORTANT: Connecting to remote machines will require launching RunningLow with elevated priviledges and having the Windows Management Service up, running and reachable (TCP port 5985) on the remote machine.

- volumes

A colon-separated list of the drive volumes (letters) to check: set it to $null to check all local (non-network) drives.

Example: $volumes = "C:D";

- email_to

If specified, will send a low-disk-space warning email to the given colon-separated addresses.

Example: $email_to = "[email protected]:[email protected]";

Default is $null (no e-mail will be sent). Replace it with [email protected] if you don't want to set it from the CLI.

- email_username = "[email protected]"
- email_password = "yourpassword"
- email_smtp_host = "smtp.yourdomain.com"
- email_smtp_port = 25
- email_smtp_SSL = 0
- email_from = "[email protected]"

The above parameters can be used to set up your SMTP configuration for sending the e-mail alerts: username, password & so on. It's strongly advisable to set them within the code instead of setting them from the CLI, as you might rarely want to change them. Needless to say, if you don't want RunningLow to send any e-mail, you might as well skip the whole part: just remember to set -email_to value to $null to have the code skip that as well.

The Code

The first ten or so lines host the configuration settings, which you should change accordingly to your needs and depending to your specific scenario. The most important thing to understand is the first line: as we can see, we can either specify an array of drives – including network drives, as long as they’re permanently mapped to a local drive letter – or set a null value: if we go for the latter, the script will check all local drives.

The comments should be enough to guide you through this required part: however, if you need further assistance, you can use the comment section of this post to submit your query and I’ll do my best to help you with that.

Testing

As soon as you’re done with the configuration, you can test the script from the standard Windows Command Prompt with the following command:

1

powershell -executionpolicy bypass -File RunningLow.ps1

… Or by typing
.\RunningLow.ps1 from a PowerShell prompt.

As soon as you hit ENTER, you should see something like this:

RunningLow - A free PowerShell script to check for low disk space and send e-mail to System Administrators

… Meaning that everything went ok.

Sending E-Mail Alerts

Needless to say, you should then edit the script, raise the $minSize value to a ridiculously high amount (such as 5TB) and run another test to ensure that the e-mail alerts will actually be sent:

RunningLow - A free PowerShell script to check for low disk space and send e-mail to System Administrators

… That’s it.

Installing

It goes without saying that the script should not be launched manually: the best thing we can do to ensure that it will be executed on regular basis is to create an appropriate entry in the Windows Task Scheduler. In the example below, RunningLow will be executed once a day at noon:

RunningLow - A free PowerShell script to check for low disk space and send e-mail to System Administrators

In the New Action window you can either insert the full execution statement (including parameters) in the Program/script textbox, or use the Add arguments (optional) textbox: the script will work either way. Similarly, you can specify the full path of the RunningLow.ps1 file within the -File parameter or put it into the Start in (optional) textbox, just like we did in the above screenshot.

IMPORTANT: In the scheduled task General tab, be sure to activate the options Run whether the user is logged on or not and Run with highest priviledges, otherwise the script would run only if there’s a logged-in user during the execution time.

Be sure to test it again – by setting an insanely high $minSize – on the server as well, to be sure that there are no firewalls or other restrictions that would block the e-mail alerts.

Well, that’s it for now: I sincerely hope that you will enjoy having RunningLow on your servers just like I do!

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].