I’ve got a snippet of code that runs differently in PSVersion 5.1 and 7.4:
"server1.domain.com","server2.domain.com" | % { @{ ComputerName = $_; CopySucceeded = ( Test-Path "C:\temp\foo.bar" ) } } | Export-Csv C:\Temp\foo.csv -Append -Force -NoTypeInformation
When ran in 7.4 I get these results:
When ran in 5.1, I get this result:
Does anyone know what has changed to allow this to work now in 7.4 or which version began to allow this?
I’ve been trying to mess around in 5.1 to see how to export this, but not quite getting it with ConvertFrom-CSV
. Is there a way to Export-CSV
in 5.1 without declaring headers to get a similar output from 7.4?
"server1.domain.com","server2.domain.com" | ConvertFrom-Csv -Header ('ComputerName', 'CopySucceeded') | Export-Csv C:\Temp\foo5.1.csv -Append -Force -NoTypeInformation