I have two seperate rows in my csv. So two different hosts and values I want to manipulate.
Im calling the foreach to grab the first host, connect to it and get/set vmkernel IP. Then its supposed to discconnect from the host
Then grab the next host in the csv, connect to it, get/set different vmkernel IP. Then disconnect.
In actuality, what is happening is that the first host is completed successfully, everything is set right.
When the second host gets to set the vmkernel IP (with a different value than host 1), it then goes back and sets the second hosts vmkernel IP on the first host as well.
What gives? Im stuck.
foreach ($line in $csv)
{
#################################################################################
# Set Variables
#################################################################################
$newhost = $line.host
$var1 = $line.var1
$var2 = $linevar2
...
...
#################################################################################
# Connect to Hosts
#################################################################################
Connect-VIServer $newhost -User $vmhost_user -Password $vmhost_pass
#################################################################################
# Get VMKernel PortGroup and Assign IP and Subnet4
#################################################################################
Write-Host "Find the VMKernel PortGroup on Host $newhost and Assign New IP and Subnet to it!" -ForegroundColor Green
$vmkernel0 = Get-VMHostNetworkAdapter $newhost | where { $_.PortGroupName -eq "SAN 0" }
Set-VMHostNetworkAdapter -VirtualNIC $vmkernel0 -IP "$var1" -SubnetMask "$var2" -confirm:$False
Disconnect-VIServer $newhost