{"id":135792,"date":"2015-07-30T10:39:49","date_gmt":"2015-07-30T03:39:49","guid":{"rendered":"http:\/\/www.icez.net\/blog\/?p=135792"},"modified":"2015-07-30T10:39:49","modified_gmt":"2015-07-30T03:39:49","slug":"windows-server-email-alert-when-user-log-in","status":"publish","type":"post","link":"https:\/\/www.icez.net\/blog\/135792\/windows-server-email-alert-when-user-log-in","title":{"rendered":"0213 | \u0e43\u0e2b\u0e49 Windows Server \u0e2a\u0e48\u0e07\u0e40\u0e21\u0e25\u0e41\u0e08\u0e49\u0e07\u0e40\u0e15\u0e37\u0e2d\u0e19\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e21\u0e35 login"},"content":{"rendered":"<p>\u0e17\u0e33\u0e41\u0e25\u0e49\u0e27\u0e01\u0e47\u0e08\u0e14\u0e44\u0e27\u0e49\u0e04\u0e23\u0e31\u0e1a<\/p>\n<p>\u0e01\u0e48\u0e2d\u0e19\u0e2d\u0e37\u0e48\u0e19\u0e2a\u0e23\u0e49\u0e32\u0e07 powershell script \u0e40\u0e0b\u0e1f\u0e44\u0e27\u0e49\u0e0b\u0e31\u0e01\u0e17\u0e35\u0e48 (\u0e2a\u0e21\u0e21\u0e15\u0e34 c:\\scripts\\email.ps1)<\/p>\n<pre>$message=Get-WinEvent -logname \"Microsoft-Windows-TerminalServices-LocalSessionManager\/Operational\" -maxevents 10 | Where-Object {$_.Id -eq 21 -OR $_.Id -eq 25 } |Format-List -Property * | out-string -Width 100\nsend-mailmessage -to EMAIL@EXAMPLE.COM -Subject \"Login Event on <server>\" -SmtpServer mail.domain.com -From db1@warz.extreme.co.th -Body $message<\/pre>\n<p>\u0e40\u0e15\u0e23\u0e35\u0e22\u0e21 smtp server \u0e43\u0e2b\u0e49\u0e40\u0e23\u0e35\u0e22\u0e1a\u0e23\u0e49\u0e2d\u0e22\u0e14\u0e49\u0e27\u0e22\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a<\/p>\n<p>\u0e41\u0e25\u0e49\u0e27\u0e44\u0e1b\u0e17\u0e35\u0e48 task scheduler \u0e01\u0e14 create task \u0e2b\u0e19\u0e49\u0e32\u0e41\u0e23\u0e01\u0e01\u0e23\u0e2d\u0e01\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e19\u0e35\u0e49<\/p>\n<p><a href=\"http:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102458.png\" rel=\"lightbox[135792]\"><img decoding=\"async\" src=\"http:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102458.png\" alt=\"c-102458\" width=\"492\" class=\"alignnone size-medium wp-image-135794\" srcset=\"https:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102458.png 655w, https:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102458-300x228.png 300w\" sizes=\"(max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p>\u0e41\u0e25\u0e49\u0e27\u0e44\u0e1b\u0e17\u0e35\u0e48\u0e2b\u0e19\u0e49\u0e32 Trigger \u0e01\u0e14 New \u0e41\u0e25\u0e49\u0e27\u0e01\u0e23\u0e2d\u0e01\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e19\u0e35\u0e49 (\u0e0a\u0e48\u0e2d\u0e07 Event Log \u0e19\u0e31\u0e48\u0e19 \u0e01\u0e23\u0e2d\u0e01 Microsoft-Windows-TerminalServices-LocalSessionManager\/Operational \u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a)<\/p>\n<p><a href=\"http:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102403.png\" rel=\"lightbox[135792]\"><img decoding=\"async\" src=\"http:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102403.png\" alt=\"c-102403\" width=\"492\" class=\"alignnone size-medium wp-image-135795\" srcset=\"https:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102403.png 947w, https:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102403-300x180.png 300w\" sizes=\"(max-width: 947px) 100vw, 947px\" \/><\/a><\/p>\n<p>\u0e41\u0e25\u0e49\u0e27\u0e44\u0e1b\u0e17\u0e35\u0e48\u0e2b\u0e19\u0e49\u0e32 Action \u0e01\u0e14 New \u0e01\u0e23\u0e2d\u0e01\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e19\u0e35\u0e49<\/p>\n<p><a href=\"http:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102438.png\" rel=\"lightbox[135792]\"><img decoding=\"async\" src=\"http:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102438.png\" alt=\"c-102438\" width=\"492\" class=\"aligncenter size-full wp-image-135793\" srcset=\"https:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102438.png 492w, https:\/\/www.icez.net\/blog\/wp-content\/uploads\/2015\/07\/c-102438-284x300.png 284w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/a><\/p>\n<p>\u0e40\u0e2a\u0e23\u0e47\u0e08\u0e41\u0e25\u0e49\u0e27\u0e01\u0e14 OK \u0e2d\u0e2d\u0e01\u0e44\u0e1b \u0e21\u0e31\u0e19\u0e08\u0e30\u0e16\u0e32\u0e21\u0e23\u0e2b\u0e31\u0e2a\u0e1c\u0e48\u0e32\u0e19 windows \u0e17\u0e35\u0e19\u0e36\u0e07\u0e01\u0e47\u0e43\u0e2a\u0e48\u0e43\u0e2b\u0e49\u0e40\u0e23\u0e35\u0e22\u0e1a\u0e23\u0e49\u0e2d\u0e22 \u0e08\u0e1a :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e17\u0e33\u0e41\u0e25\u0e49\u0e27\u0e01\u0e47\u0e08\u0e14\u0e44\u0e27\u0e49\u0e04\u0e23\u0e31\u0e1a \u0e01\u0e48\u0e2d\u0e19\u0e2d\u0e37\u0e48\u0e19\u0e2a\u0e23\u0e49\u0e32\u0e07 powershell script \u0e40\u0e0b\u0e1f\u0e44\u0e27\u0e49\u0e0b\u0e31\u0e01\u0e17\u0e35\u0e48 (\u0e2a\u0e21\u0e21\u0e15\u0e34 c:\\scripts\\email.ps1) $message=Get-WinEvent -logname &#8220;Microsoft-Windows-TerminalServices-LocalSessionManager\/Operational&#8221; -maxevents 10 | Where-Object {$_.Id -eq 21 -OR $_.Id -eq 25 } |Format-List -Property * | out-string -Width 100 send-mailmessage -to EMAIL@EXAMPLE.COM -Subject &#8220;Login Event on &#8221; -SmtpServer mail.domain.com -From db1@warz.extreme.co.th -Body $message \u0e40\u0e15\u0e23\u0e35\u0e22\u0e21 smtp server \u0e43\u0e2b\u0e49\u0e40\u0e23\u0e35\u0e22\u0e1a\u0e23\u0e49\u0e2d\u0e22\u0e14\u0e49\u0e27\u0e22\u0e19\u0e30\u0e04\u0e23\u0e31\u0e1a \u0e41\u0e25\u0e49\u0e27\u0e44\u0e1b\u0e17\u0e35\u0e48 task scheduler \u0e01\u0e14 create task \u0e2b\u0e19\u0e49\u0e32\u0e41\u0e23\u0e01\u0e01\u0e23\u0e2d\u0e01\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e19\u0e35\u0e49 \u0e41\u0e25\u0e49\u0e27\u0e44\u0e1b\u0e17\u0e35\u0e48\u0e2b\u0e19\u0e49\u0e32 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5698],"tags":[5700,129,5699,5694],"class_list":["post-135792","post","type-post","status-publish","format-standard","hentry","category-windows-server","tag-alert","tag-monitor","tag-powershell","tag-windows-server"],"_links":{"self":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/135792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/comments?post=135792"}],"version-history":[{"count":5,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/135792\/revisions"}],"predecessor-version":[{"id":135801,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/135792\/revisions\/135801"}],"wp:attachment":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/media?parent=135792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/categories?post=135792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/tags?post=135792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}