Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Need an explanation of why this works, please.

$
0
0

So I was trying to output some data to a csv file within Powershell using the Export-CSV command.  It worked, but one of the properties (the value propertyI was exporting has arrays of values.  Because of this, the data in the CSV file would simply show up as "System.String[]"

I know that this is because the property that it was trying to output was an array of values and could not save it that way, but I found someone that had a solution that works.  I just don't understand what some of it is doing.

The code I was using:

select OptionID, Name, Value

The code he used was this:

select OptionID, Name, @{l="Value";e={$_.Value -join " "}}

The section after the NAME property is what is like magic to me.  Instead of using the "Value" property, they used @{l="Value";e={$_.Value -join " "}}

The part I don't understand is how Powershell knows what l= and e= are.  Is it something that is built into properties or into Powershell itself?

I know that the join is joinig all of the array values into a string and the segments on both sides of the ; look like its' a replace, but I can't for the life of me find anything on what l= and e= represent.  Can you do that with any property on any object?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>