title: How to lock a file during the process and unlocked after finished using PowerShell?
body: <p>I have an infinity loop process. I will check a file, once the file exist, then I process it.
  Is it possible if I found the file, then I lock it, so people will not able to open or modify the file until the process finish.</p>
  
  <pre><code>do{
       if(Test-Path -Path ".\Data.txt")
       {
            $file = Get-content -Path ".\Data.txt"
            ## do some process ##
            #
            #
            #
            #
            #modify the file extension to .don once
            # process
            #
            #FINISHED (the process will finished once the extension modified)
       }
  }
  
  while(1)
  </code></pre>
  
  <p>Anyone can give idea please. Thank you.</p>