Installing NSX-T with a PowerCLI Script
PowerCLI can be very useful to automate tasks in a number of different use cases.
On my home lab, I sometimes need to deploy new instances of NSX-T for testing purposes. Instead of installing those manually, I have created a simple script to automate this process.
Instructions on how to install PowerCLI can be found at:
https://developer.vmware.com/powercli/installation-guide
As usual, I feel compelled to say that this is not an official VMware resource, so please use it at your discretion.
# Deploy NSX-T Manager
#------------------------------------------------------------------------#
# Deployment Variables (Modify as required)
# Path to the OVA file
$ova_file = "C:\Temp\nsx-unified-appliance-3.2.1.0.0.19801963.ova"
# Target ESXi Host information
$cluster = "Management"
$esxi_host = "esxi.raulcunha.local"
$datastore = "Datastore-1"
# Appliance Information
$root_password = "VMware1!VMware1!"
$admin_password = "VMware1!VMware1!"
$audit_password = "VMware1!VMware1!"
$VM_name = "NSX-Manager"
$hostname = "nsx-manager.raulcunha.local"
$ipaddress = "10.0.0.65"
$netmask = "255.255.255.128"
$gateway = "10.0.0.1"
$dns = "10.0.0.2"
$ntp = "10.0.0.3"
$domain = "raulcunha.local"
# Appliance Role options: "NSX Manager", "nsx-cloud-service-manager", "NSX Global Manager"
$appliance_role = "NSX Manager"
# Appliance Size options: "extra_small", "small", "medium", "large"
$appliance_size = "medium"
$portGroup = "Management-PG"
#------------------------------------------------------------------------#
#-- OVF Deployment --#
# Connect to vCenter Server
Connect-VIServer vcenter.raulcunha.local
# NSX Manager Configuration
$nsxmgrcfg = Get-OvfConfiguration $ova_file
$nsxmgrcfg.Common.nsx_passwd_0.Value = $root_password
$nsxmgrcfg.Common.nsx_cli_passwd_0.Value = $admin_password
$nsxmgrcfg.Common.nsx_cli_audit_passwd_0.Value = $audit_password
$nsxmgrcfg.Common.nsx_hostname.Value = $hostname
$nsxmgrcfg.Common.nsx_ip_0.Value = $ipaddress
$nsxmgrcfg.Common.nsx_netmask_0.Value = $netmask
$nsxmgrcfg.Common.nsx_gateway_0.Value = $gateway
$nsxmgrcfg.Common.nsx_dns1_0.Value = $dns
$nsxmgrcfg.Common.nsx_ntp_0.Value = $ntp
$nsxmgrcfg.Common.nsx_domain_0.Value = $domain
$nsxmgrcfg.Common.nsx_role.Value = $appliance_role
$nsxmgrcfg.Common.nsx_isSSHEnabled.Value = $true
$nsxmgrcfg.Common.nsx_allowSSHRootLogin.Value = $true
$nsxmgrcfg.DeploymentOption.Value = $appliance_size
$nsxmgrcfg.IpAssignment.IpProtocol.Value = "IPv4"
$nsxmgrcfg.NetworkMapping.Network_1.Value = $portGroup
# Deploy Appliance
Import-Vapp -Source $ova_file -OvfConfiguration $nsxmgrcfg -Name $VM_name -VMHost $esxi_host -Location $cluster -Datastore $datastore -Confirm:$false
—