I run a script to process a CSV file once an hour. At the beginning of the script, I need to exit out if the CSV file has not changed. Let's pretend that file timestamps aren't an option. (I'm asking this question for educational value)
I was considering slurping in the entire file and computing the hash on the contents, like so:
$fileData = get-content \path\to\file
$hashCode = $fileData.GetHashCode()
I would then save those contents from run to run, and if the hash is the same on subsequent runs, exit out of my script.
Is there a better way to do this, again, assuming file timestamps are not available?