7
5
I need to read a file on a remote pc which is frequently modified. As it so happens, it appears that my script is sometimes colliding with a write on the file, rendering it inaccessible. I cannot change the way the file is written to so I have to work with what I have.
I ran a test by having a script continuously reading a file with Get-Content and subsequently starting another script which writes to the file at frequent intervals. At times, the write operation was not possible.
Is it possible that I use get-content on a remote pc without locking the file?
Thank you for your input, however this still locks the file to a write, if my testing is correct. – lcam – 2017-03-06T13:19:39.793
How do you perform your testing? I didn't get any locks while testing this code snippet. – t1meless – 2017-03-12T19:44:25.933
Never mind, my testing was in fact incorrect. I researched a bit so I could modify your code to read the last couple of lines of the file rather than read the whole lot of it as that was taking some time and conflicting with a write. This seemed to have solved the issue, thanks! – lcam – 2017-03-16T15:53:55.740