I am trying to connect to my local ESXi hosts using an array that holds the host names. First I log into the vCenter and create the array, then try and connect using the array. I keep getting Invalid URI: The hostname could not be parsed. What am I missing here? I do know that when I dump this to a txt file there seems to be white space at the end of each server name.
Connect-VIServer (MyvCenter) -User (My Username)-Password (My Password)
$esxiServers = get-vmhost | select-object Name
ForEach ($server in $esxiServers)
}
Connect-VIServer $server -User (My Username) -Password (My Password)
}
I am planning on using an encrypted password later. I am just trying to get this to work.