Quantcast
Channel: VMware Communities : Discussion List - Automation Tools
Viewing all articles
Browse latest Browse all 9071

Hash Table custom object

$
0
0

Hi I have the following script which should provide a table with vm names and the datastorecluster they reside on:-

 

$hashT=@{}

$vmlist = Import-Csv "C:\vmMove\vm3.csv"

foreach ($vm in $vmlist)

{

$vmname = get-vm $vm.name

$dscname = get-datastorecluster -vm $vm.name

 

 

$hashT = @{

VMNAME = $vmname

DSCLUSTER = $dscname

}

}

$props = New-Object psobject -Property $hashT

$props | ft -AutoSize

There are four hosts listed in the csv file but when I run this the table it only writes out one line for the last host it doesnt include the the first three hosts.  What Am I doing wrong? why cant I get the hash table to display details for all hosts contained in csv.

 

I've spent the best part of a day on this and just cant see where I'm going wrong - thanks


Viewing all articles
Browse latest Browse all 9071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>