If that's what you're doing, then what's in the $computer variable at that time? If the value is coming from the CSV, then how did you specify the column (i.e., property) in the current row?
Using Powershell to manipulate .csv from AD query
I've written a Powershell script to automate a process we have been doing manually, but for some reason it does not work when using a .csv of machines exported from AD. If I query AD for machines with a certain property, output the results to a .csv which are then read into an array and subsequently run any cmdlet on the machines in the array, the cmdlet doesn't fail but always returns a negative result. For instance, if I run "test-connection -ComputerName $computer" on a computer manually, against a manually created array or an array created from a manually created .csv it returns the proper results. However, if I run the same command against a .csv created from running the Get-ADComputer cmdlet, all machines return false even if they're up and running. Is there anything "under the hood" with Powershell that would cause incorrect results such as then when machines are exported from AD?