I am going through our entire environment making a change where the mac address of the management nic changes. Long story short, on each host I am having to manually login to the console and do a network restore. I'd like to try to program this as you can login through powershell to a host directly. I happened upon a page http://searchvmware.techtarget.com/tip/PowersHell-Factory-Reset-of-ESXi which shows doing a complete factory reset through powershell. I just want to restore the network settings to default.
The code in the webpage is:
$vmhost = "esx4.vi4book.com"
$vcname = "virtualcenter4.vi4book.com"
#Connect to vCenter & Enter Maintenance Mode
Connect-VIServer $vcname -username administrator -password vmware
$esxhost = Get-VMHost $vmhost
$hostview = $esxhost | Get-View
Set-VMHost $esxhost -State maintenance
# Remove ESX host from vCenter...
Remove-VMHost $vmhost -Confirm:$false
# Carry out factory reset...
Connect-VIServer $vmhost -username root -password password
$esxhost = Get-VMHost $vmhost
$hostview = $esxhost | Get-View
$ns = Get-View -Id $hostview.ConfigManager.firmwareSystem
$ns.ResetFirmwareToFactoryDefaults()
I've looked around a bit in the API but haven't found anything yet.