Powercli script to create a new vswitch and enable it for iscsi

By | 9th December 2014

The following script creates a new vswitch by name iscsi
Adds vmnic1 as the physical adapter
adds the portgroup iscsi

Interesting Note: to make the portgroup as vmkernel easy method to say -ConsoleNic:$false.


$VC=”″ #vcenter server

Connect-VIServer -Server $VC -User $user -Password $password

$esxall=Get-VMHost -Server $VC

foreach($esx in $esxall){

$vswitch = New-VirtualSwitch -Name iscsi -Nic vmnic1 -VMHost $esx
New-VMHostNetworkAdapter -VMHost $esx -PortGroup iscsi -ConsoleNic:$false -VirtualSwitch iscsi