, ,

NSX-T | Getting Started with PowerCLI

Hi Guys,

I am working on PowerCLI for NSX-T and trying to do all the operations as we could do in NSX-V. it is bit different yet simple so I thought to share what I have learned so far. below is a glimpse of the same. 

Also, there is a good article from VMware for the beginners to understand the same. I too learned from here but I was able to do more operations by understanding the given basics in the above link.

Explore it and let me know if you need any assistance with it. 

To connect NSX-T manager in PowerShell

#Connect-NsxtServer -server FQDN\IP


To get NSX-T manager details
function nsxnode{$nodesvc = Get-NsxtService com.vmware.nsx.node
$nodesvc.get()



To get the transport zone name and its relevant id
$tzone = Get-NsxtService com.vmware.nsx.transport_zones
(($tzone.list()).results) | Select display_name, ID


To get the name of all logical switch's name

 $tls = Get-NsxtService com.vmware.nsx.logical_switches
(($tls.list()).results).display_name



To get the name of all logical routers' name
$Tier1 = Get-NsxtService -Name com.vmware.nsx.logical_routers
($Tier1.list()).results.display_name



To create Tier-1 or Tier-0 router
$rname = Read-Host "Tell me the Tier-1 router name to set"
$tier1 = Get-NsxtService -Name com.vmware.nsx.logical_routers
$createt1 = $tier1.Help.create.logical_router.Create()
$createt1.display_name = $rname
$createt1.router_type = "TIER1" #Change it to TIER0 if you want to create Tier0 router
$tier1.create($create1)


To create logical switch
$segments = Get-NsxtService com.vmware.nsx.logical_switches
$createls = $segments.Help.create.logical_switch.create()
$createls.admin_state = "UP"

$createls.transport_zone_id = "Enter ID here"
$createls.display_name = "Enter any name here"

$createls.replication_mode = "MTEP"
$segments.create($createls)


To delete logical switch
$logswitchname = Read-Host "Enter the LS name to delete"
#Delete Logical Switch
$logswitchsvc = Get-NsxtService -Name com.vmware.nsx.logical_switches
$logswitches = $logswitchsvc.list().results
$logswitch = $logswitches | Where-Object {$_.display_name -eq $logswitchname}
$logswitchsvc.delete($logswitch.id)



That's it for now but I will keep on adding in the list. In my next post, you will be seeing like connect LS with tier-0 or tier-1 and connect LS with VM with all IP configuration, etc.



Thank you,
vCloudNotes

1 comment:

  1. Great idea man thanks keep it up all the time. I am very happy to see your standard. Also get the detailed knowledge about the NSX T 3 Edge Cluster Failover by just moving towards our website.

    ReplyDelete