This isn't possible. Get-Content literally just calls the underlying provider for the path you give it. For the file system provider it is probably calling the File.ReadAllText
method which is just a wrapper around the underlying Win32 file operation. There is no concept of "previous versions" built into any of this.
It sounds to me like you have a timing issue here. However you haven't shared any details on when this file gets updated, what the "previous version" means and what your script is doing. Off the top of my head some things that come to mind:
- You're trying to read a file that is on a distributed file system or perhaps OneDrive and so the version you're reading is a cached copy that hasn't been updated yet. PS has no control over this.
- You're using the File History feature of NTFS and something isn't right about it. PS has no control here either.
- You are writing the file at the same time you're trying to read it so depending upon how the file is being written determines when you'd see the updated file contents.
- Your script is programmatically figuring out the file to load and it is loading the wrong file.
There are other possibilities but without an understanding of what your script does it would be hard to guess.