I’m looking for some help if possible. Please bear in mind I am a complete PowerShell novice so feel free to dumb things down as appropriate. Also apologies if this is in the wrong section
End Product - Report/CSV to show all “missing files” between an SQL output compared to existing files in a directory - Essentially, what orders are in SQL, compare this to filenames in a directory, any files that are missing needs to be exported
I need to compare an SQL CSV output that is always in a format of 12345 (order number) to a directory search of filenames (pdf’s) 12345.pdf
However, when users have been saving files, they call them either 12345, 012345 or 0012345
We now need to find these files and match against the original SQL export number.
I have created several arrays to hold the data but I just cannot find a way to compare them and spit out the “missing” files. If it was just one format of filename this wouldn’t be an issue, however it several formats (with the leading zeros)
In my head it is something like.
Foreach item in $Array1 (Order numbers)
Compare to array2 (Pdf files in a directory),
If not found try array3 (has a 0 appended to beginning of each number found in $Array1)
If not found try array4 (has a 00 appended to beginning of each number $Array1)
If still not found, export or write-host anything you can’t find
For example, the SQL export will be 12345, the file (if it exists) could be either 12345.pdf, 012345.pdf or 0012345.pdf
Any help would be greatly appreciated.
Please see attached “code” (if that’s the right word for what I have written )