admin
Immortal
Immortal

How To: Configure freshly booted ESX with PowerShell

Jump to solution

As part of a larger project I've been working on a set of scripts which configure a freshly-installed ESX (or ESXi) system into Virtual Center (after first attempting to remove previous VC state and clean state from the host). Currently they follow a typical post-boot configuration pattern:

  1. Set ESX password

  2. Add to Virtual Center cluster

  3. Configure Virtual Switches

  4. Configure Port Groups

  5. Add NFS partitions

  6. Add iSCSI partitions

  7. Configure NTP

  8. Configure VMotion

Before trying, modify esx-master.ps1 and esx-profile.ps1 to local conditions (or your password will be set to "CHANGEME").

Command: esx-autoconfigure.ps1 "hostname|ip-address"

As this is my initial foray into PowerShell, please excuse any idiosyncracies.

This is a work-in-progress - feedback welcome. Points awarded for the best suggestions in the next few days.

lance

(2008-Sep-02 - I've moved the script files to )

0 Kudos
29 Replies
240Zeus
Enthusiast
Enthusiast

I'd love to but unfortunately the process at my current employer requires manucal verification of the input parameters for auditing purposes.

I like how you're thinking though!

0 Kudos
240Zeus
Enthusiast
Enthusiast

Exactly, SC!

We're mainly LInux on our VM side so I already have the entire infrastructure setup for kickstarts already. And your point regarding ESXi is spot on.

So when will VMware include a PS configuration script configurator similar to the kickstart configurator? Smiley Happy

0 Kudos
SCampbell1
Enthusiast
Enthusiast

The DHCP is just to get the thing started. I agree you want to verify the inputs for auditing purposes and use static addresses

If you do have a PS provisioning script, you can pipe the string outputs of the script to a log file using Tee-Object. This can then be your installation record. Also fairly easy to maintain a data store (e.g., CSV file, SQL table) of configuration inputs if you want to retrieve settings from a separate source.

My ESX provisioning example at NAEPS is fairly hands free and fairly complete, however, it doesn't do the DHCP or the static kickstart bits. We had to stop somewhere.

0 Kudos
halr9000
Commander
Commander

Where's the kickstart configurator?






[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
LucD
Leadership
Leadership

See Appendix B in ESX Server 3 and VirtualCenter Installation Guide


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ChrisRu
Enthusiast
Enthusiast

great & coll stuff what you are do here

But I search for a way to modify the DNS-Servers and the dns search domains with powershell.

I tried itt with set-VMHostnetwork but this doesn't work.

thanks

Christian

0 Kudos
LucD
Leadership
Leadership

See for changing the DNS servers.

You can use the searchDomain property to define the search domains.

$dnsServers = ("192.168.111.3","192.168.111.4")

Get-VMHost | Get-View | %{
   $ns = Get-View -Id $esx.configManager.networkSystem
   $dns = $ns.networkConfig.dnsConfig
 
    $dns.Address = @()
    foreach($server in $dnsServers) {
      $dns.Address += $server
  }
  $dns.searchDomain = ("domain1.xyz","domain2.abc")
  $ns.UpdateDnsConfig($dns)
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ChrisRu
Enthusiast
Enthusiast

Thanks for that.

0 Kudos
Windspirit
Hot Shot
Hot Shot

Just a bit improvement: just define an array for the DNS servers instead of filling it form a list. The searchlist is just an char field...

$dnsServers = @("192.168.111.3","192.168.111.4")

Get-VMHost | Get-View | %{$ns = Get-View -Id $esx.configManager.networkSystem

$dns = $ns.networkConfig.dnsConfig

$dns.Address = $dnsservers

$dns.searchDomain = "domain1.xyz, domain2.abc"  
$ns.UpdateDnsConfig($dns)}

0 Kudos
admin
Immortal
Immortal

These are great ideas to improve configuring the DNS. I will add them to a future version of the scripts.

lance

0 Kudos