I need to check and return files that exist in the filesystem, but are not listed in a given text file. For instance, my text file (sample.txt) will contain paths like:
\\SharedDrive\Data\DevS\Common\app_name\subfolder1\Archive\Archive1.vbproj
\\SharedDrive\Data\DevS\NotCommon\app_name\subfolder1\user\WebApp.vbproj
\\SharedDrive\Data\DevS\UnCommon\app_name\subfolder1\Manager\Managerial.vbproj
It happens that there are VB project files that exists on the drive but are not among the list, which i want to return along with their full path. For instance:
\\SharedDrive\Data\DevS\Common\app_name\subfolder2\Windows\SharedArchive.vbproj
\\SharedDrive\Data\DevS\NotCommon\app_name2\subfolder1\user2\WebApp2.vbproj
I tried this:
$log = "e:\pshell\notExists.log"
Get-Content "e:\pshell\Sample.txt" | Where-Object {
#Keep only paths that does not exists
!(Test-Path $_)
} | Set-Content $log
but this does the other way around.