ESXI PowerShell command to Automate ESXI configuration

 # Prompt for vCenter password

$VCCred = Get-Credential

$vCenter = Read-Host "Enter vCenterName"

#$targetVC =

#Connect vCenter 

#Connect-VIServer -Server $vCenter -Credential $VCCred

$DataCenter1= Read-Host "Enter Datacenter host"

#$datacenter = Get-Datacenter "Demo_DC"

#Prompt for ESXI

$ESXI = Read-Host "Enter ESXI hostName" 

$ESXICred= Get-Credential

#Connect ESXI host

Connect-VIServer -Server $ESXI -Credential $ESXICred

# Add NTP server details

$NTPServer=Read-Host "Write NTP server details"

#Add-VmHostNtpServer -VMHost $esxi -NtpServer servername

#Add-VMHostNtpServer -VMHost $esxi -NtpServer

Add-VMHostNtpServer -VMHost $ESXI -NtpServer $NTPServer

# Create Datastore

$DataStore= Read-Host "Volume Name"

#Storage Device path

$DevicePath= Read-Host "Enter Storage device path"

#New-Datastore -VMHost $ESXI -Name $DataStore -Path mpx.vmhba0:C0:T1:L0 -VMFS -FileSystemVersion 6

New-Datastore -VMHost $ESXI -Name $DataStore -Path $DevicePath -Vmfs -FileSystemVersion 6

# To update Domain name, prefered DNS and SearchDomain

$vmHostNetworkInfo = Get-VmHostNetwork -Host $ESXI

Set-VmHostNetwork -Network $vmHostNetworkInfo -VMKernelGateway -DomainName -SearchDomain -DnsAddress -DnsFromDhcp $false

#Add host to vCenter

Add-VMHost -Server $targetVC -Name $ESXI -Location $DataCenter1 -Credential $ESXICred -Force

#Enable Storage IO Control

Set-Datastore -Datastore $DataStore -StorageIOControlEnabled $true

No comments:

Post a Comment

Featured Post

HPE MSA 2040 configuration step by step

HPE MSA 2040 configuration Default IP range for HP SAN storage MSA 2040 is You need to connect your laptop and storage with...