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?

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

Open in new window

You can pipe from that into Export-CSV, or use Select-Object to choose specific properties, etc.
0
 
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
1
 
Indie101Author Commented:
Admin...Can i amend this to give fox 150 points and the rest to footech please?
0
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.