VMware Cloud Community
sjesse
Leadership
Leadership
Jump to solution

Get memory for virtual machines in order of imported csv

I recently exported the names of all of our virtual machines, then organized over 400 of them in different groups. I neglected to also export the memory so I'm trying to import an csv get the memory and export that to a csv. That way I can just copy and paste the memory from one spreadsheet to another. I think I'm missing something simple but I can't see it I am trying this

$servers=Import-Csv C:\Users\sjesse\Desktop\sdcvms.csv

$vms=@()

foreach ($server in $servers)

{

    $vm=Get-VM -Name $server.Name select Name, Description, PowerState, NumCpu, MemoryGB

    $vms+=$vm

}

$vms | Export-Csv "C:\vms.csv" –NoTypeInformation

and I keep geting this error

VM with name '<name of the server>' was not found using the specified filter(s).

The name in the error is the exact name I see in vcenter, and was an exported by using get-vm to get all of the virtual machine names using this.

Get-VM | select Name | Export-Csv -path “c:\vminventory.csv” –NoTypeInformation

so I can't see why I can't find the VMs.

Reply
0 Kudos
1 Solution

Accepted Solutions
sjesse
Leadership
Leadership
Jump to solution

That wasn't it. I figured I was wasting so much time trying to get this code to work, I just re exported all of the vms again with the memory this time, and reorignized them. Thanks for the suggestion.

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You seem to be missing the pipeline symbol after the Get-VM

$vm=Get-VM -Name $server.Name | select Name, Description, PowerState, NumCpu, MemoryGB


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
sjesse
Leadership
Leadership
Jump to solution

That wasn't it. I figured I was wasting so much time trying to get this code to work, I just re exported all of the vms again with the memory this time, and reorignized them. Thanks for the suggestion.

Reply
0 Kudos