Wednesday, January 1, 2020

PowerNSX | Create Logical Switches in bulk



Let's create multiple Logical switches in bulk with PowerNSX.

Simply copy below script and paste in your Powershell(I prefer Powershell ISE) console.

#Start here
$NSXManagerIP = "IP Address" #Mention NSX Manager IP address here in quote(")
$VCenterIP = "IP Address" #Mention vCenter Server IP address here in quote (")
$NSXManagerUser = "admin" #NSX manager admin username goes here
$NSXManagerPassword = "Password" #NSX manager admin password goes here
$VCenterUser = "administrator@vsphere.local" #Write down vCenter server admin username
$VCenterPassword = "VCenterPassword" #vCenter server admin password goes here

#Give the path of csv file containing name of all logical switches
$NSXLOGICALSWITCHFILE = import-csv C:\work\NSX_PowerNSX\Logical_Switch_Creation.csv

#Connect NSX Manager with below command
Connect-NsxServer -Server $NSXManagerIP -Username $NSXManagerUser -Password $NSXManagerPassword -ViUserName $VCenterUser -ViPassword $VCenterPassword

$LS = 0

#apply the loop here to create the number of logical switches equivalent to the number of LS names mentioned in above csv file
foreach ($LogicalSwitch in $NSXLOGICALSWITCHFILE)
{
## Creates Logical Switches for NSX. Possible Control Plane Modes are UNICAST_MODE,HYBRID_MODE,MULTICAST_MODE
Get-NsxTransportZone | New-NsxLogicalSwitch -Name $LogicalSwitch.LogicalSwitchName -ControlPlaneMode UNICAST_MODE

$LS++
Write-Progress -Activity "Creating Logical Switches" -status "Created: $LS of $($NSXLOGICALSWITCHFILE.Count)" -PercentComplete (($LS / $NSXLOGICALSWITCHFILE.Count) * 100)

}

Write-Host "!!!All Logical Switches Created Sucsessfully" -ForegroundColor Green

#End here

0 comments:

Post a Comment

Sponsor

AD BANNER
Powered by Blogger.
The Magazine

Text Widget

Facebook

Extra Ads

AD BANNER

Welcome to my Notes!

Hello Folks, My name is Gautam Johar. Actively working on VMware Cloud and keen to learn new and latest cloud technologies in market. Love ...

Contact Form

Name

Email *

Message *

Followers



Labels

Translate

Breaking

Random Posts

Follow Us

On Linkedin

Recent Posts

Recent Comments

Header Ads

Popular Posts

Popular Posts

Recent Posts

Text Widget

Search This Blog

Copyright © test blog | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com