Querying Virtual machines ????

by GeorginaHowland at 2012-12-17 09:43:53

I am trying to query a list of virtual machine servers
first command displays the two servers queried (this worked)
second command testing Import-csv (this worked)
third command get-vm from imported csv this did not work

I don’t know why it did not work, I would like to query virtual machines from an imported CSV file. I don’t understand the error, what syntax would i require? Commands below

PowerCLI C:\temp> get-vm -name cbsffm001, cbsapp105

Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
CBSAPP105 PoweredOn 2 4.000
cbsffm001 PoweredOn 2 4.000


PowerCLI C:\temp> import-csv c:\temp\servers.csv

Name
----
cbsffm001
cbsapp105


PowerCLI C:\temp> Get-vm (IMport-csv c:\temp\servers.csv)
Get-VM : 2012-12-17 12:34:13 Get-VM VM with name ‘@{Name=cbsffm001}’ was not found using the specified filter(s).
At line:1 char:7
+ Get-vm <<<< (IMport-csv c:\temp\servers.csv)
+ CategoryInfo : ObjectNotFound: (:slight_smile: [Get-VM], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Get-VM : 2012-12-17 12:34:13 Get-VM VM with name ‘@{Name=cbsapp105}’ was not found using the specified filter(s).
At line:1 char:7
+ Get-vm <<<< (IMport-csv c:\temp\servers.csv)
+ CategoryInfo : ObjectNotFound: (:slight_smile: [Get-VM], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM
by aadkins1964 at 2012-12-17 11:25:02
This should work.

[code2=powershell]Import-Csv test-vms.csv | foreach {get-vm $_.name}[/code2]
by GeorginaHowland at 2012-12-17 12:14:39
That worked Thank you