I have a CSV file with a four headings, the most important being the IP address. What I need to do is search through a file certain file directory and all of its child files and directories to see if the IP address is NOT contained within any files. If the IP address is not contained within any of the files, add the IP address to an array, and continue checking all IP addresses. Once done, list the contents of the array.
$Path = "C:\Users\Me\Desktop\nagios\configs\hosts"
$NotMonitoredArray = @()
$servers = Import-Csv "C:\wpg-export.csv"
foreach ($item in $servers) {
Get-ChildItem $Path -Recurse | Where-Object {
$_.Attributes -ne "Directory"
} | ForEach-Object {
if (Get-Content | Where-Object { !(Select-String -Pattern $_.IPAddress -Quiet) }) {
$NotMonitoredArray += $_.IPAddress
}
}
}
It is getting stuck at the Get-Content cmdlet specifically saying
cmdlet Get-Content at command pipeline position 1
Supply values for the following parameters:
Path[0]