I wrote a function to take a number of files I wanted hashed as an array of fully qualified file paths. The function then iterates over the array to build a giant PowerShell command containing all the paths, parses the output of PowerShell and returns a dictionary with each of the fully qualified files as an index and it’s hash as the value.
It’s supposed to be a black box into which you pass an array of files and receive a dictionary of all those files and their hashes. It works well, but I did discover a limit. I got an error when trying to send a text string that was too big to fit into the buffer to run the command. So I had to update my function to check how big the string was getting. When it got too large, I’d run the previous string to get those files, then restart the string with the file that was likely to crash the command, and continue looping until the entire array was processed.
I thought I’d include my dirty programming here if you dare to look at it. It might turn you to stone like looking at Medusa without a mirror! It’s that horrid right now. I am going to refactor it, but shipped it as is so my customer could continue their work.
Maybe as a “fun” exercise, YOU could refactor the function for me. If so, I’ll credit you in a later message.
For now, I have a few things in there you don’t really need to track timings and you should also get a copy of the PS_GetOutput command from here: DevHut’s Daniel Pineault’s VBA PowerShell Function with Update | Access JumpStart. Or back on DevHut.
Trackbacks/Pingbacks