October 30, 2014

Powershell Function about EventLog

Filed under: Tips — donrsh @ 11:39 am
function Measure-Site
    $URLListFile = "C:\yourname\URLList.txt"
	$URLList = Get-Content $URLListFile -ErrorAction SilentlyContinue
	Foreach ($Uri in $URLList)
            $countrycode = (Get-Content c:\yourname\URLListcountry.txt)[$s_no]
            $countrynumber = (Get-Content C:\yourname\CountryNumber.txt)[$s1_no]
		    $Time = Measure-Command {
			C:\yourname\MainScript.ps1} #see previous post on the blogg
            $LogFileExist = Get-EventLog -list | Where-Object { $_.LogDisplayName -eq "ScriptCheck" }
			if (! $LogFileExist)
				New-EventLog -LogName "ScriptCheck" -Source "Scripts"
			if ($Time.Totalseconds -lt 25)
				Write-EventLog -LogName "ScriptCheck" -Source "Scripts" -EntryType information -EventId $countrynumber -Message " $countrycode `nTotal Time: $Time"
			elseif ($Time.Totalseconds -gt 25)
				Write-EventLog -LogName "ScriptCheck" -Source "Scripts" -EntryType warning -EventId $countrynumber -Message " $countrycode  `nTotal Time: $Time"



if (Get-Process -name iexplore -ErrorAction SilentlyContinue)
	Stop-Process -Name iexplore

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: