Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $allhandles = get-process
- $today = [DateTime]::Now
- $thisComputer = $env:computername
- foreach($handle in $allhandles){
- $data = ""
- if($handle.handlecount -gt 2500)
- {
- if($handle.ProcessName -eq "lsass" -or $handle.ProcessName -eq "System" -or $handle.ProcessName -eq "Store" -or $handle.ProcessName -eq "sqlserver") {
- }
- else{
- $data = $today, $handle.ProcessName, $handle.handlecount | Out-File "C:\temp\handles.log" -Append
- if($handle.HandleCount -gt 10000)
- {
- Send-MailMessage -To SYSADMIN@YOURDOMAIN.COM -From ALERT@YOURDOMAIN.COM -Subject "Excessive handle count detected: $thisComputer" -Body "An open file with a high handle count has been deteced. $handle.ProcessName - $handle.HandleCount" -SmtpServer SMTPSERVER.YOURDOMAIN.COM
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement