LineNumber not reporting correctly
hi everyone
i've been working on side project of mine helps me learn powershell , incorporate other languages, , i've hit bit of roadblock.
my powershell script reads latest entry (the last line) of logfile everytime logfile has been updated. when logfile updates, script reads last line of logfile , searches 2 specific words; gamestart , gameend.
once finds 'gamestart' supposed remember linenumber , continue read latest entries until finds 'gameend' , remember linenumber.
i'm using section of code monitor logfile updates:
for testing purposes, have below lines confirm if position of gamestart , gameend reports correct line number:
try
$gamestart = @(get-content 'c:\path-to-log\logfile.log' | select-string -pattern '(gamestart)')[-1] $gameend = @(get-content 'c:\path-to-log\logfile.log' | select-string -pattern '(gameend)')[-1]
Windows Server > Windows PowerShell
Comments
Post a Comment