Format into hashtable

by Mar 5, 2016

Hi I'm trying to create a table containing vm name and the datastorecluster they are contained within, no matter what I try I cant seem to create the table I can list the object as follows:-


$vmlist = Get-Content 'C:vmlistvm2.txt'

foreach ($vm in $vmlist){

get-vm $vm | select name

get-vm $vm | get-datastorecluster


But as soon as I try to create a hash table from the above it just doesn't work no matter which approach I take, can anyone help?