Advertisement
guyrleech

Show some (log) file contents from a specific offset in file

Jan 16th, 2020
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Read specific amount of string data from a (log) file at a given offset like you might see being written in a SysInternals procmon trace
  2. $fileStream = New-Object System.IO.FileStream( "path_to_logfile_to_read" , [System.IO.FileMode]::Open , [System.IO.FileAccess]::Read )
  3. [int]$offset = 132433
  4. $fileStream.Seek( $offset , [System.IO.SeekOrigin]::Begin )
  5. [int]$bufsize = 4123
  6. $chunk = New-Object byte[] $bufSize
  7. $fileStream.Read( $chunk , 0 , $bufsize )
  8. $fileStream.Close()
  9. [System.Text.Encoding]::ASCII.GetString( $chunk )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement