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