Deploy OVA with PowerCLI

It has been a while since I have written anything for my blog. Life has become crazy busy for me the last few months. Between normal work and family time I do not have a lot of free time. The following meme really sums up my life right now.

I have had to deploy a few OVA recently, but wanted to let those that are a little less technical have an easy quick way to accomplish this. Its not that complicated of a script, but it works and gets the job done. By using the Read-Host capability it allows user input into a Powershell script which can really expand Powershells capabilities.

connect-viserver “Your vCenter”

$vmSource = Read-Host – Prompt “File path to OVA”

$vmCluster = Get-Cluster – Name “Name of Cluster you want to use”

$vmHost = ($vmCluster | Get-VMHost)

$vmDatastore = Get-Datastore -Name “Name of Datastore to be used”

$vmName = Read-Host -Prompt “What to name VM?”

$vmHost | Import-vApp – Source $vmSource -Location $vmCluster -Datastore $vmDatastore -Name $vmName -Force

Set NTP on all host in vCenter

Here is a Powershell script that will set NTP on all the ESX host connected to your vCenter.

First connect to the vCenter using Connect-VIserver then run the following code.

 

#Get Host
write-host “Gathering ESX Host”
$esx = get-vmhost

#Configure NTP server
write-host “configuring NTP”
Add-VmHostNtpServer -VMHost $esx -NtpServer 10.10.16.220

#Allow NTP queries outbound through the firewall
wrtie-host “Setting Firewall Permissions”
Get-VMHostFirewallException -VMHost $esx | where {$_.Name -eq “NTP client”} | Set-VMHostFirewallException -Enabled:$true

#Start NTP client service and set to automatic
write-host “Starting NTP service”
Get-VmHostService -VMHost $esx | Where-Object {$_.key -eq “ntpd”} | Start-VMHostService
Get-VmHostService -VMHost $esx | Where-Object {$_.key -eq “ntpd”} | Set-VMHostService -policy “automatic”

 

Default Isolation Address

If a host thinks it is isolated by default it will ping its gateway.  It is best practice to have more than one isolation address, and you can have up to 10 of these.  Duncan Epping has a good article on it here.  Here is a simple script I found somewhere on the web.

$cluster = Get-Cluster -Name ITN

New-AdvancedSetting -Entity $cluster -Type ClusterHA -Name ‘das.isolationaddress1’ -Value 1.2.3.4

New-AdvancedSetting -Entity $cluster -Type ClusterHA -Name ‘das.usedefaultisolationaddress’ -Value false

#Disable and reenable HA

Set-Cluster -Cluster $cluster -HAEnabled:$false

Set-Cluster -Cluster $cluster -HAEnabled:$true

Blog at WordPress.com.

Up ↑