Subscribe to Windows IT Pro

What's the $($this.that) PowerShell syntax mean?

It's hard to read, but it can be convenient.
Posted @ 11/11/2011 9:56 AM By Don Jones

 

I've recently started answering questions over at PowerShell.com, and a great one came in this morning:


I was recently writing a script to process some data from a CSV file using Import-CSV. I was having an issue so I went out and looked for an example that I could use. The example I found used syntax that I haven't seen explained but seems to be used frequently and I was hoping you could explain. I've simplified the example as it really is the syntax that throws me.

What is with the "$()" syntax wrapping the column1 value as both methods seem to work just fine?

foreach($Line in $CSVFile)
{
$Column1 = "$($line.Column1)"
$Column2 = $line.Column2
}


Read the full response, and provide your own thoughts and comments.

Related Content:

Comments

Add A Comment
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.