PowerCLI Script to add NIC to virtual machines
#Connect to vcenter server
Connect-viserver vcenter_server
#Get the network name as input
$VLAN = Read-Host "Enter the Network Name"
#Get the list of virtual machines from the servers.txt
$vm = gc c:\temp\servers.txt
#Assign a new NIC to all the VM listed in servers.txt with VMXNET3 as type
Get-VM $vm | New-NetworkAdapter -Type Vmxnet3 -NetworkName $VLAN -WakeOnLan:$true -StartConnected:$true -Confirm:$false
#Disconnect from vcenter server
Disconnect-VIServer vcenter_server -Confirm:$False
No comments:
Post a Comment