VMware Cloud Community
admin
Immortal
Immortal
Jump to solution

How To: Configure freshly booted ESX with PowerShell

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 )

Reply
0 Kudos
29 Replies
240Zeus
Enthusiast
Enthusiast
Jump to solution

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!

Reply
0 Kudos
240Zeus
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
SCampbell1
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
halr9000
Commander
Commander
Jump to solution

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
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

See Appendix B in ESX Server 3 and VirtualCenter Installation Guide


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

Reply
0 Kudos
ChrisRu
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
ChrisRu
Enthusiast
Enthusiast
Jump to solution

Thanks for that.

Reply
0 Kudos
Windspirit
Hot Shot
Hot Shot
Jump to solution

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)}

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

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

lance

Reply
0 Kudos