VMware Cloud Community
fatpat94
Contributor
Contributor

How to send Ctrl-Alt-Del to a GuestOs ?

Hello all,

I'm looking for a way to send Ctrl-Alt-Del to a vm from powercli script.

It's for a linux guest os (rhel6) I'm trying to install via PXE. The vmware-tools are installed automaticaly by anaconda and the Wait-Tools cmdlet is working great.

But the Restart-VMGuest cmdlet does not work because the system in which the vmware tools are installed can't issue a reboot or shutdown as the system is in fact chrooted.

The only way I have is to send Ctrl-Alt-Del to the guest os but I can't find how to achieve this from a powercli script.

Thanks you so much.

++ Jerome

PS: here is the script I'm using:

$vm = get-vm test_vm

$vm | Set-Jumpstart # switch the network card to the correct vlan
$vm | Set-BootOrder -Value net # switch the boot order to allow:net
$vm | Start-VM -Confirm:$false # start the vm
$vm | Wait-Tools # wait for the install is finished (the vmware-tools are installed and launched
$vm | Set-BootOrder -Value hd # set to boot order to hd
$vm | Restart-VMGuest # Does not work because the system in which the vmware tools are installed is chrooted
$vm | Restore-Network # switch back the network cad to its original vlan

PS2: I'm using the last vsphere/vix/powercli/esxi versions

Tags (3)
0 Kudos
5 Replies
LucD
Leadership
Leadership

Did you try sending a bash script via the Invoke-VMScript cmdlet ?

You can use the root credentials on the  GuestUser/GuestPassword parameters to avoid the chrooted problem.

The bash script can trigger the reboot.


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

0 Kudos
fatpat94
Contributor
Contributor

Hi LucD,

thanks for you reply. I can use Invoke-VMScript but it would have no effects. The target system is chrooted and does not have access to reboot/shutdown functions, they simply don't work.

But the hosted system can intercept Ctrl/Alt/Del so the VM can be reseted this way. I can't even do a power reset because the machine has to be shutdown cleanly.

As there is an options in the vCenter client interface, I think there should be a way to trigger the same event via powercli.

0 Kudos
LucD
Leadership
Leadership

I'm not sure I understand the problem correctly.

When you run the bask script with root, it should be rather easy to break out of the chroot limitation and thus invoke the reboot command.

If that is not possible, you will have to look at the VIX API calls to trigger the reboot.


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

0 Kudos
fatpat94
Contributor
Contributor

I'l try to explain more precisely the problem.

I'm trying to PXE install a RHEL 6 linux system into a VM. All the installation is done automaticaly.

The PXE boots a simple linux into RAM and execute anaconda (which is the installation program from fedora/redhat). The target system is then chrooted into /mnt/sysimage.

After the installation is finished a postinstall script is executed. In this postinstall script, the vmware-tools are installed and launched. But the postinstall script is executed within the chroot (/mnt/sysimage). So the vmware tools only sees the chrooted system (/mnt/sysimage) and from the chroot it's not possible to reboot or shutdown the system.

# chroot /mnt/sysimange

# reboot

Unable to shutdown system

So calling VM-GuestRestart will have exactely the same effects and every script launched from Invoke-Script will run within the chroot.

That's why I'm looking for a way to send Ctrl-Alt-Del to the VM.

0 Kudos
peterli9295
Contributor
Contributor

I don't know whether the below script is able to help you, however, it helps me to do the similar action.

I'd like to auto-install a VM via a silent installation package, after setting the booting CD to my ISO, I restart the VM to trigger the auto-installation via the below script:

restart-vm -vm (get-vm -name <vmName>) -confirm:$false

I suggest you to try the above script to see the final result before you draw your own decision.

0 Kudos