Dude, Where’s My Missing Files?

Hello!

One of the reasons I love PowerShell is that something that might you think would take a bit of effort turns out to be no effort at all.

You want proof? OK, how about this:

Recently I had been helping a team migrate from TFS to VSTS. But what with a complex branching strategy this turned out to be more difficult than initially thought. And at some point we had a discrepancy in files and folders.  And whilst TFS/VSTS are great at source control, I needed to find out just what was missing and figure out why.

I knew that I could use “Get-ChildItem” to get all the items, but how could I compare? Simples: Compare-Object. By using Compare-Object I could compare the contents of the two folders and, get this, it would tell me which folder is missing what file in both directions. Neat. And though the output only showed the filename, I could use -Passthru and get the FullName of each object, and save it to a file. Neat and tidy.

Leave a Reply

Your email address will not be published. Required fields are marked *