VMware Cloud Community
tvliew
Contributor
Contributor
Jump to solution

Automated connection of network adapter of guest machine after guest machine boots up

Hi Al,

I am running VMWare ESXi 4 Update 1. I am running a pair of Astaro Security Gateway firewall guest machines in HA mode on my ESXi 4. My problem is that when both guest machines are running in HA mode, they are fine. However, when I reboot one of them with its virtual NIC cards set to 'Connect at power on', it doesn't 'sync' up with one another. The two Astaro Security Gateway firewalls have a separate NIC connected to one another for HA SYNC.

However, when I uncheck the 'Connect at power on' and allow the guest machine to fully bootup and then 'connect' the virtual NICs, they work fine.

Is there a way to automate the connection of the network adapter of the guest machines after, say, x seconds after they are powered on?

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can connect the network adapter 60 seconds after the startup of your virtual machine with the following PowerCLI script:

# Get the VM
$VM = Get-VM YourVMname

# Get the network adapter
$VMNetworkAdapter = $VM | Get-NetworkAdapter

# Disable "Connected" and "Connect at power on" on the network adapter  
$VMNetworkAdapter | `
  Set-NetworkAdapter -StartConnected:$False -Connected:$False -Confirm:$False

# Start the VM
Start-VM -VM $VM

# Wait for 60 seconds
Start-Sleep -Seconds 60

# Enable "Connected" on the network adapter  
$VMNetworkAdapter | `
  Set-NetworkAdapter -Connected:$True -Confirm:$False

Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can connect the network adapter 60 seconds after the startup of your virtual machine with the following PowerCLI script:

# Get the VM
$VM = Get-VM YourVMname

# Get the network adapter
$VMNetworkAdapter = $VM | Get-NetworkAdapter

# Disable "Connected" and "Connect at power on" on the network adapter  
$VMNetworkAdapter | `
  Set-NetworkAdapter -StartConnected:$False -Connected:$False -Confirm:$False

# Start the VM
Start-VM -VM $VM

# Wait for 60 seconds
Start-Sleep -Seconds 60

# Enable "Connected" on the network adapter  
$VMNetworkAdapter | `
  Set-NetworkAdapter -Connected:$True -Confirm:$False

Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
tvliew
Contributor
Contributor
Jump to solution

Hi RvdNieuwendijk,

I am not very familar with PowerCLI so I googled on this and saw that it is one of VMWARE's tools. I think I will download this and figure out how to use your script. Thanks so much. I wasn't aware of this.

0 Kudos