Most users are more concerned about the latest logs, here is a simple example to get the last few lines of line from a text log: # show the latest 5 rows of windowsupdate.log files $logs = Get-content-path $env: windir \windowsupdate.log-readcount 0$logs[-5..-1] The above example returns the last 5 lines of text in the Windows Update log file. It is very efficient to perform because Get-content uses the –readcount 0 parameter. Readcount refers to the number of lines of text sent to the pipe each time, 0 for all, and 0 more efficient in the current scenario. However, there is another criticism, variable $logs will be in the form of an array of text stored in memory, and still contiguous memory. So there's a more efficient way to do this in PowerShell 3.0. # Displays the latest 5 rows of Windowsupdate.log files Get-content-path $env: Windir\windowsupdate.log-readcount 0-tail 5 The tail parameter here allows the get-content command to return only the text of the specified end line number. This avoids the problem of a large amount of text content residing in memory. Reference link: Accessing Latest Log File Entries
Explanation of the Get-content parameter-readcount