Hi ,
I am trying to add a vmkernel switch and network adapter , I am reading host names and ip addresses from two diferent text files .
In my code I've nested the foreach loop.
The loop is not seem to work . Can anyone help me , I have idea of using delimiter and use CSV file rather than text file
my code is as follows
Connect-VIServer
$esxs
= Get-Content c:\scripts\test.txt
$ips
= Get-Content c:\scripts\ip.txt
foreach
($esxs in $esxs)
{
foreach
($ips in $ips)
{
$vswitch
= New-VirtualSwitch -VMHost $esxs -Name "vMotion" -Nic vmnic2
New-VMHostNetworkAdapter
-VMHost $esxs -PortGroup "vMotion" -VirtualSwitch $vswitch -IP $ips -SubnetMask 255.255.255.0 -VMotionEnabled $true VLanID 4000
}
}