• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 754
  • Last Modified:

looking for a powershell script that will check for low disk space on approx. 10 win2k8 servers and send an email alert if the space drops below 15%

can someone provide a script that will check for low disk space on a set of servers [reference a .txt file for the server list] and send out an email alert if the space drops below 15% on any of them in the list?

I also have the quest AD commandlets installed if you have a version of the quest posh script that can accomplish this.

many thanks,

S.

0
siber1
Asked:
siber1
1 Solution
 
soostibiCommented:
This is a prototype for this:
Get-Content c:\serverlist.txt | ForEach-Object {Get-WmiObject -Class Win32_LogicalDisk -ComputerName $_ -Filter "drivetype=3"} | %{
    Add-Member -InputObject $_ -MemberType noteproperty -Name freepercent -Value ($_.freespace/$_.size*100) -PassThru
} | ?{$_.freepercent -lt 15} | ForEach-Object {
    $message = "Low disk space on server $($_.__server) on disk $($_.name), actual free size $([int] $_.freepercent)%"
    
    Send-MailMessage -Body $message -From PowerShellScript@yourdomain.com -To YourRecipient@yourdomain.com -SmtpServer mail.yourdomain.com -Subject "Low disk space notification"
}

Open in new window

0
 
siber1Author Commented:
excellent! just what i was looking for.
thx much!
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now