Saturday, February 11, 2023

Here is a handy bit of PowerCLI to return the VMhost Name, Product, ESXi build, Serial number of all hosts in vCenter.

 

Run below syntax on powercli to get the VMhost Name, Product, ESXi build, Serial number of all hosts in vCenter.



Get-Vmhost | Get-View | Sort-object Name |
select Name,
@{N='Product';E={$_.Config.Product.FullName}},
@{N='Build';E={$_.Config.Product.Build}},
@{Name="Serial Number"; Expression={($_.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag"}).IdentifierValue}}




OR


Get-VMHost | Get-View | Select Name, @{l=”SerialNumber”; e={$_.Hardware.SystemInfo.OtherIdentifyingInfo.IdentifierValue.split(“,”)[0]}}

Thursday, February 9, 2023

Create NSX-T segments using the terraform


Export the template from GitHub  https://github.com/vmware/terraform-provider-nsxt and modify the template as mentioned below.


“`variables.tf“` file mention the manager IP, user name, password

# NSX Manager
variable "nsx_manager" {
  default = "IP here"
}


# Username & Password for NSX-T Manager
variable "username" {
  default = "user name here"
}

variable "password" {
    default = "password here"
}

 

This is the “`main.tf“` file:

# Prerequisites: 
# 1. Add NSX-T License

# Data Sources we need for reference later
data "nsxt_policy_transport_zone" "overlay_tz" {
    display_name = "Overlay-TZ"
}

data "nsxt_policy_transport_zone" "vlan_tz" {
    display_name = "VLAN-TZ"
}

# NSX-T Manager Credentials
provider "nsxt" {
    host                     = var.nsx_manager
    username                 = var.username
    password                 = var.password
    allow_unverified_ssl     = true
    max_retries              = 10
    retry_min_delay          = 500
    retry_max_delay          = 5000
    retry_on_status_codes    = [429]
}


# Create NSX-T VLAN Segments
resource "nsxt_policy_vlan_segment" "vlan100" {
    display_name = "VLAN100"
    description = "VLAN Segment created by Terraform"
    transport_zone_path = data.nsxt_policy_transport_zone.vlan_tz.path
    vlan_ids = ["11"]
}



ESXI-check multiple ports using one command

  [root@ESXI:~] nc -w 1 -z IP 80-902 Connection to IP 80 port [tcp/http] succeeded! Connection to IP 88 port [tcp/kerberos] succeeded! Conne...