Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dnsstatus = 1
- $pingstatus = 1
- $localstatus = 1
- $filelocation = 'C:/log/internetlog.txt'
- $ScriptBlock = {
- param($addr)
- Test-Connection $addr -Quiet -count 1 -timetolive 100
- }
- while(1){
- Start-Job $ScriptBlock -argumentlist "google.com"
- Start-Job $ScriptBlock -argumentlist "1.1.1.1"
- Start-Job $ScriptBlock -argumentlist "192.168.1.1"
- start-sleep -m 50
- while (Get-Job -state "Running") {start-sleep -m 10}
- ($dnstest, $pingtest, $localtest) = Get-Job | Receive-job
- get-job | remove-job
- $date=Get-Date
- if ($dnstest -and !$dnsstatus){
- $text = 'DNS resolved connections resumed working at ' + $date
- $text >> $filelocation
- $dnsstatus = 1
- }
- if (!$dnstest -and $dnsstatus){
- $text = 'DNS resolved connections stopped working at ' + $date
- $text >> $filelocation
- $dnsstatus = 0
- }
- if ($pingtest -and !$pingstatus){
- $text = 'IP resolved connections resumed working at ' + $date
- $text >> $filelocation
- $pingstatus = 1
- }
- if (!$pingtest -and $pingstatus){
- $text = 'IP resolved connections stopped working at ' + $date
- $text >> $filelocation
- $pingstatus = 0
- }
- if ($localtest -and !$localstatus){
- $text = 'local connections resumed working at ' + $date
- $text >> $filelocation
- $localstatus = 1
- }
- if (!$localtest -and $localstatus){
- $text = 'IP resolved connections stopped working at ' + $date
- $text >> $filelocation
- $localstatus = 0
- }
- Start-Sleep -s 10
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement