I'm new with powershell and I'm pretty sure my question is quite easy for experts. I have a CSV file with this table. 
I want to write a script where I give a variable $name, and get its state if it exists in the machine column. I tried to do something like this:
$csv=Import-Csv C:\data.csv -Delimiter=","
foreach ($row in $csv){
$machine=$row.Machine
If ($machine=$searched_name){
$searched_state=$row.State}
}
But this clearly does not work.
Anyone can help me please ?
Thanks. !
Import-Csv C:\data.csv | Where-Object { $_.Machine -eq "m1" }If ($machine=$searched_name){<<< is an assignment, not a comparison. [grin] you need to use-eqinstead of=.=on a parameter as well like you do in-Delimiter=","Use a space instead. Besides, if the delimiter used is a comma, you can leave that out entirely, because a comma is the default.;is the default in some locales - kinda like the use of,instead of.for numeric delims.