Forum Discussion
campbelm01
Mar 04, 2021Copper Contributor
No Output cvs file
Hi, I have the following code.. It runs with no errors but does not give any output: $rec_cnt = 0 $data_conv = (Get-Content $destFile2) $result = foreach ($line in $data_conv) { $line.host if (...
AndySvints
Mar 05, 2021Iron Contributor
Hello campbelm01,
I think the problem you are facing is related to usage of Get-Content cmdlet.
The Get-Content cmdlet gets the content of the item ... for files, the content is read one line at a time and returns a collection of objects, each of which represents a line of content.
Later in your loop you are referring to $line properties but because of Get-Content your $line is a string.
What type of file are you trying to read? Is it csv?
Please try to use Import-Csv.