5 pts.
 Powershell script for counting files and emailing results
I need to find a script that will count files in a directory and return results via email if they exceed a certain amount. I am trying to automate a manual process. I am not a Powershell expert, but I am trying to learn. Can anyone point me in the right direction?

Software/Hardware used:
Windows 2008 R2 on VMware 4.1
ASKED: September 13, 2012  8:52 PM

Answer Wiki:
This should do it. This is provided as is and with no warranty. if you need anything else contact me at colin@dbyay.com
$path = "Path to check"
$files = ls $path 
$fcount = $files.count
if{$fcount -gt 5)
{
Send-MailMessage -SmtpServer "yourserver.domain.com" -To "email address" -From "from address" -Subjuct "files in $path exceeded threshold" -Body "File count in path is $fcount"
}
Last Wiki Answer Submitted:  February 11, 2013  5:18 pm  by  Colin Smith   845 pts.
All Answer Wiki Contributors:  Colin Smith   845 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _