Check Logs file using Powershell

./psexec.exe \\Server “c:\Program Files\Windows Media Player\wmplayer.exe”
start-sleep -seconds 30
$AllCompfiles=get-content compfiles.txt
foreach($file in $AllCompfiles) {
$FilePath=”\\Server\c$\Program Files\Windows Media Player\LOGs\”
#write-host  $FilePath$file

if(Test-Path $FilePath$file){
$Lastwritetime=(get-childitem $FilePath$file).lastwritetime
$CurrentTime=get-date
$TimeDiff=($CurrentTime-$Lastwritetime).totalminutes
if($TimeDiff -lt 30) {
write-host “$file is up to date”
}
else{write-host $file is out of date -foreground RED }
}
}

===========Contents of  compfiles.txt============

File1

File2

===========Contents of  compfiles.txt============

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: