Import csv file to get-network adapter of multiple vms

Using below script

Get-network adapter -vm (Then i list about 60 vms)

I then pipe it to a csv document, is there a handy way to pipe it in the first place from a csv?

Who is Participating?
You mean like this? (assumes .CSV with a header named "computer")
Import-CSV file.csv | ForEach { Get-network adapter -vm $ }

Open in new window

You can pipe from that into Export-CSV, or use Select-Object to choose specific properties, etc.
FOXActive Directory/Exchange EngineerCommented:
As footech mentioned have a header of computer or vmname and run the below with the file location of your .csv file.
In my example we will assume the header is vmname and the .csv file  is in the temp folder of the c: drive

Import-Csv 'c:\temp\machines.csv' | %{Get-NetworkAdapter -VM $_.vmname | Select MacAddress,Id,Name} | Export-csv 'c:\temp\results.csv' -notypeinformation
Indie101Author Commented:
Admin...Can i amend this to give fox 150 points and the rest to footech please?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.