Sometimes you need to lock file and investigate how an application under the test will be working.
There are few steps to implement it:
$file=[System.io.File]::Open('full/path/to/your/file', 'append', 'Write', 'None')
P.S.: It’s possible that it’ll be the error in your application log:
Exception calling "Open" with "4" argument(s): "The process cannot access the file 'full/path/to/your/file'' because it is being used by another process."