for the folders that are on the list but NOT in the network drive
How about something like this?
$Folders = Import-Csv "c:\temp\files.csv"
$Found = @() # Array of names that we found
$NotFound = @() # Array of names that we did not find
foreach ($Folder in $Folders) {
"Searching for {0}" -f $Folder.Name
$Results= Get-Childitem -Path "c:\temp" -recurse -include $Folder.Name
"I found {0} objects" -f $Results.count
# Add entry into appropriate array
if ($Results.count -eq 0) {
$NotFound += [PSCustomObject]@{
Name = $Folder.Name
}
} else {
$Found += [PSCustomObject]@{
Name = $Folder.Name
Count = $Results.count
}
}
}
$Found | Export-Csv c:\temp\Found.csv -NoTypeInformation
$NotFound | Export-Csv c:\temp\NotFound.csv -NoTypeInformation
"Here are the names that I found."
Get-Content c:\temp\Found.csv
"Here are the names that I did not find."
Get-Content c:\temp\NotFound.csv