Have a Question?
< All Topics
Print

Initial Setup of ESXi Host with PowerCLI

Tutorial on how to perform initial setup of ESXi host with PowerCLI

Installation of VMware PowerCLI

Install VMware PowerCLI referring to this link and verify the version with Get-PowerCLIVersion

Get-PowerCLIVersion

Connect to ESXi Host

Connect to VMware ESXi Host

$ESXi = "192.168.1.189"
$User = "root"
$Password = "P@ssw0rd!@#$"

Connect-VIServer -Server $ESXi -User $User -Password $Password -WarningAction SilentlyContinue

Enable SSH Access & NTP

Change SSH Service Policy to Start & Stop with Host and start SSH Service

Get-VMHostService | ? {$_.Key -eq "TSM-SSH" } | Set-VMHostService -policy "On" | Start-VMHostService

Supress SSH warning

Get-VMHost | Get-AdvancedSetting UserVars.SuppressShellWarning |
Set-AdvancedSetting -Value 1

Setup NTP Server to point to time.windows.com and change NTP Daemon Policy to Start & Stop with Host.

$NTPServer = "time.windows.com"
Add-VMHostNtpServer -NtpServer $NTPServer

# Start NTP Daemin Service
Get-VMHostService | ? {$_.Key -eq "TSM-SSH" } | Set-VMHostService -policy "On" | Start-VMHostService

IP Address, DNS & Gateway

Change Managment IP Address & Subnet mask

$VMHost_IP = "192.168.1.190"
$VMHost_SubnetMask = "255.255.255.0"

Get-VMHostNetworkAdapter -VMKernel | ? ManagementTrafficEnabled -eq "True" | Set-VMHostNetworkAdapter -IP $VMHost_IP -SubnetMask $VMHost_SubnetMask

Configure DNS Servers,Default Gateway and Domain Name for Management Network

$VMHost = Get-VMHost
$VMHostNet = Get-VMHostNetwork
$VMHost_Name = "ESX01"
$VMHost_DomainName = "aventislab.com"
$VMHost_SearchDomain = "aventislab.com"

Set-VMHostNetwork -Network $VMHostNet -Hostname $VMHost_Name -DomainName $VMHost_DomainName -SearchDomain $VMHost_SearchDomain -DnsFromDhcp $false `
-DnsAddress 1.1.1.1,8.8.8.8 -VMKernelGateway "192.168.1.1"

vSwitch, Port Group and Uplinks

Create a new vSwitch

$vSwitch_Name = "LAN"
$vSwitch_LAN = New-VirtualSwitch -VMHost $VMHost -Name $vSwitch_Name 

Add vmnic1 & vmnic2 to vSwitch

$VMHost_vmnic1 = Get-VMhost | Get-VMHostNetworkAdapter -Physical -Name vmnic1
$VMHost_vmnic2 = Get-VMhost | Get-VMHostNetworkAdapter -Physical -Name vmnic2
$vSwitch_LAN | Add-VirtualSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $VMHost_vmnic1 -Confirm:$false
$vSwitch_LAN | Add-VirtualSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $VMHost_vmnic2 -Confirm:$false

Remove vmnic2 from vSwitch

Remove-VirtualSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $VMHost_vmnic2 -Confirm:$false

New Port Group for vSwitch

New-VirtualPortGroup -VirtualSwitch $vSwitch_LAN -Name LAN_Production

Table of Contents
Scroll to Top