I am a newbie having difficulties.
I have a CSV file that I need to read. It has 3 fields. Field1 is a descriptor. Fields 2 and 3 are file paths
to other files whose content I need to read (with filtering). The CSV file format is as follows:
Contents of C:\PowerShell_INPUT\FileList.csv:
Descriptor, RemotePort , FileDigit
Test0, “\vavt-neb-pds1\d$\Pds\Test0\ddmscpic.ini”, “\vavt-neb-pds1\d$\Pds\Test0\omniweb.ini”
Test1, “\vavt-neb-pds1\d$\Pds\Test1\ddmscpic.ini”, “\vavt-neb-pds1\d$\Pds\Test1\omniweb.ini”
etc., etc
I need to read the 3 values of each record in the CSV, retrieve the contents of the remote file paths
represented by Field_2 and Field_3 (while filtering the content with a search string). Once I have the data , I
need to write my results to my output text file.
Here is what I have so far:
Clear-Host
$inputFilePath = “C:\PowerShell_INPUT\FileList.csv”
$outputFilePath = “C:\PowerShell_INPUT\OutputList.txt”
$csv = Import-csv -path $inputFilePath |
foreach ($line in $csv)
{
Get-Content $line |
ForEach-Object { $descriptor = $.Descriptor; $RemotePortFilePath = $.RemotePort ; $FileDigitFilePath =
$_.FileDigit |
$RemotePort = (Get-Content -path $RemotePortFilePath | ?($_ -match "RemotePort=*") ; `
$FileDigit = (Get-Content -path $FileDigitFilePath) |
Outfile -path outputFilePath - append
}
I am in the Admin group for the server where the files to be read reside, but I keep getting errors like:
Get-Content : Cannot find path ‘\vavt-neb-pds1\d$\Pds\Application\Test1\omniweb.ini’ because it does not exist.
At line:3 char:1
- Get-Content $inputFile | ForEach-Object { $_ | where { $_ -match “FileDigit=*” }
-
+ CategoryInfo : ObjectNotFound: (\\vavt-neb-pds1...st1\omniweb.ini:String) [Get-Content],
ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
Does anyone see where I am going astray?
Thanks ahead of time for any help you can provide,
Tom