function SendMail([String]$mailcontent)
{
$From = "usr@qq.com"
$To = "usr@qq.com"
$Subject = $mailcontent
$Body = $mailcontent
$Password = 'pwd' | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $From, $Password
Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer "smtp.qq.com" -port 587 -UseSsl -Credential $Credential
}
$cammer=@(
'192.168.2.23',
'192.168.2.25',
'192.168.2.27',
'192.168.2.28',
'192.168.2.29'
)
for ($i = 0; $i -lt 5; $i++){
$mailcontent = "Empty"
$nvrstor = Get-Process | Where-Object Name -eq 'NvrStorageSever'
if ( $null -eq $nvrstor){
$mailcontent = "NvrStorageSever is not running!"
#SendMail( $mailcontent )
Write-EventLog -LogName Application -Source "hknvr" -EntryType Warning -EventID 1001 -Message $mailcontent
}else{
$cammer | ForEach-Object {
$ip = $_
$tcpcnt = Get-NetTCPConnection | Where-Object {$_.RemoteAddress -eq $ip -and $_.OwningProcess -eq $nvrstor.Id}
if ($null -eq $tcpcnt)
{
$mailcontent = "IP:" + $ip + " has no tcp connetion."
#SendMail( $mailcontent )
Write-EventLog -LogName Application -Source "hknvr" -EntryType Warning -EventID 1002 -Message $mailcontent
}else{
#$mailcontent = "IP:" + $ip + " has tcp connetion."
#SendMail( $mailcontent )
}
}
}
$FindDate=Get-Date
$rsl = Get-ChildItem -Path F:\,G:\ -Include *.mp4 -File -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -le $Finddate -and $_.LastWriteTime -ge $FindDate.AddHours(-1) } | Select -First 1
if ($null -eq $rsl) {
Write-EventLog -LogName Application -Source "hknvr" -EntryType Warning -EventID 1003 -Message "No new mp4 file created!"
}
Start-Sleep 600
}
checkcammer
于 2025-01-14 17:28:00 首次发布

2万+

被折叠的 条评论
为什么被折叠?



