Compare files and Folder with different UNC paths

Hello,

I am a little bit stuck at comparing multiple files and folders.

We have 4 UNC paths and all files and folders must me exact (because of App-V 5 SCS)

Now we would like to compare these folders if all files and folders are exact.
We had a script and local it worked good.

But de server name is variable.
For example:

\\ServerA\scs$\App-V App\
\\ServerB\scs$\App-V App\
\\ServerC\scs$\App-V App\
\\ServerD\scs$\App-V App\

We created $FolderA to $FolderD and used the following script

Foreach($File in Get-ChildItem -Recurse -Path $FolderA | Where {$_.psIsContainer -eq $False} | Select-Object Name)
{$File=$File.name
    if (!(Test-Path "$FolderB\$File"))
        {Write-Output "Missing File: $FolderB\$File"}
}

When we run this script is looked it worked local. Because C:\ is the same at every check.
But running this with an UNC path he looks at ServerA till ServerD so always different and alwas incorrect.

Is there a way to exclude the first lines so we can get a exact check for files and folders?

Hope everything is clear what I mean with this and thanks in advance!

May 28th, 2015 4:39am

You need to compare file names and not paths but you need to compare single folders and not use recurse.

Start by creating a list of source folders and target folders too compare then use the list to compare for file existence.

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 5:19am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics