Home PowerShell PowerCLI Script to add port profile in ESXi Standard Switch
PowerCLI Script to add port profile in ESXi Standard Switch PDF Print E-mail
Written by Siva   
Thursday, 06 December 2012 21:07

Here is PowerCLI Script to add port profile in ESXi Standard Switch

 

Save below in a .ps1 file where you installed PowerShell/PowerCLI and execute.

 

Connect-VIServer -Server My-VC-Server

$vifcluster1 = Read-Host "Enter vifcluster Name"

$newPG = Read-Host "Enter Virtual Port Group Name"

$newVlanID = Read-Host "Enter VLAN ID"

 

$allesxhosts = Get-Cluster $vifcluster1 | Get-VMHost | Sort-Object -Property Name

 

ForEach($esxhost in $allesxhosts)

{

$vifvswitch = Get-Virtualswitch -VMHost $esxHost

Write-Host "Adding Virtual Port Group" $newPG "with VLAN ID" $newVlanID "to" $vifvswitch "on" $esxHost

New-VirtualPortGroup -Name $newPG -VirtualSwitch $vifvswitch -VLanId $newVlanID

}

 
 

Advertisement

Featured Links:
HREmail.com
Looking for job? Try HREmail.com
Want to have CMS based Websites?
Try siliconwebcreators.com to CMS based websites.
VM Solutions Inc
For best VM solutions..
Digital Procedure Inc.
Looking for Oracle /SAP /Weblogic Consulting services? visit digitalprocedure.com