Thursday, April 28, 2016

This script to test your internet connection and monitor while it is down. When the connection is back up, a text notification will show up.

Scripting Language: PowerShell
This script to test your internet connection and monitor while it is down. When the connection is back up, a text notification will show up.

# This script  to test your internet connection and monitor while it is down. When the connection is back up, a text notification will show up.
# Tested on windows 7 workstation.

Try {
    $wait=5
    $site="google.com"
    While (!(Test-Connection -computer $site -count 1 -quiet)) {
            Write-Host -ForegroundColor Red -NoNewline "Connection down..."
            Start-Sleep -Seconds $wait
    }
    #Connection is good
    Write-Host -ForegroundColor Red "$(Get-Date): Connection up!" 
    $SMTPServer = "smtp.gmail.com"
    $SMTPPort = "587"
    $Username = "username@gmail.com"
    $Password = "passwors"
    $to = "to@gmail.com"
    $subject = "Email Subject"
    $body = "Insert body text here"
    $message = New-Object System.Net.Mail.MailMessage
    $message.subject = $subject
    $message.body = $body
    $message.to.add($to)
    $message.from = $username
    $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
    $smtp.EnableSSL = $true
    $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
    $smtp.send($message)
    Write-Host "Mail Sent"
    Write-Host "Successfully passed"
    exit 0
    }
Catch {
    Write-Host "Failure"
    exit 1001
      }

PowerShell Script to Clean History , Cashe and Downloads for Internet Explorer .





$t_path_7 = "C:\Users\$env:username\AppData\Local\Microsoft\Windows\Temporary Internet Files"
$c_path_7 = "C:\Users\$env:username\AppData\Local\Microsoft\Windows\Caches"
$d_path_7 = "C:\Users\$env:username\Downloads"

$temporary_path =  Test-Path $t_path_7
$check_cashe =    Test-Path $c_path_7
$check_download = Test-Path $d_path_7

if($temporary_path -eq $True -And $check_cashe -eq $True -And $check_download -eq $True)
{
    echo "Clean history"
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

    echo "Clean Temporary internet files"
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
    (Remove-Item $t_path_7\* -Force -Recurse) 2> $null
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

    echo "Clean Cashe"
    (Remove-Item $c_path_7\* -Force -Recurse) 2> $null

    echo "Clean Downloads"
    (Remove-Item $d_path_7\* -Force -Recurse) 2> $null

    echo "Done"
}

Batch script to clear browsing history, download history, and empty the cache for Mozila Firefox.

:: Batch script to clear browsing history, download history, and empty the cache for Mozila Firefox.
:: Script can be run via GFI MAX RM
@echo off
set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
cls
IF %ERRORLEVEL%==0 (
@echo "Success Message"
timeout 10
) ELSE (
@echo "Error Message"
exit 1001
)

Batch script to clear browsing history, download history, and empty the cache for Chrome.

@echo off
set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"
cls
IF %ERRORLEVEL%==0 (
@echo "Success Message"
exit0
) ELSE (
@echo "Error Message"
exit 1001
)