Script for Booting to Windows PE using HPE iLO PowerShell Cmdlets

This blog post documents the HP/HPE iLO PowerShell commands I used for scripting the process of booting to Windows PE for purposes such as using Microsoft SCCM (System Center Configuration Manager) and/or SCO (System Center Orchestrator) runbooks for automated operating system deployment.

Thanks to Kyle Murley's blog post which led me to this.

Image

Prerequisites

  • HP iLO Cmdlets for Windows PowerShell (x86/x64) - http://www.hp.com/go/powershell (v1.3 as of this moment).
  • HP iLO Server with Advanced iLO License. (Already required by the first Mount-HPiLOVirtualMedia command) - This post is based on iLO4, but it might also work for iLO3 or others. Kindly let me know if it does for you.
  • Web server (e.g. Microsoft IIS) for hosting the Windows PE ISO file (as required by ImageURL parameter).
  • [Optional] Sysinternals Process Monitor for monitoring the download of Windows PE ISO file from the web server.
  • [Optional] HP Scripting Tools for Windows PowerShell User Guide (Also, I found the built-in command help is very useful, e.g. Get-Help Set-HPiLOVMStatus -full)

Not Covered by This Post

As the focus is on HP iLO Cmdlets, this post won't cover the below:

  • Embedding drivers into a Windows PE image.
  • Converting a boot.WIM Windows PE image to .ISO format (without "Press any key to boot from..." message). However, reference URLs are included at the bottom of this post.
  • Hosting a Windows PE ISO image on a web server for iLO to serve.

The Script (UEFI)

Web Server Recommendations

  • As the Windows PE ISO is quite large (the x64 version is about 250MB) for transferring over a WAN connection, it is recommended to use a web server which resides on the same site link as the iLO server does.
  • To increase security, consider use of HTTP over SSL (HTTPS) and/or non-common port.
  • To avoid complexity during initial testing, IP address is recommended instead of hostname/FQDN.

Additional Information

  • I noticed our new HP servers come with Generic USB Device as the first boot option by default. However, it is nice to specify it to ensure it is by the above command.
  • For UEFI, booting to Generic USB Device (Boot0008) is preferred to iLO Virtual USB CDROM (Boot000D) as the latter is not selectable after mounting the ISO with Mount-HPiLOVirtualMedia until a subsequent reboot past POST.
  • Persistent boot order is preferred to one-time boot order as the PowerShell results are more consistent. See below sections for further explanations on this.

The Script (Legacy BIOS)

There are two variants of the script. One is based on UEFI boot mode, while the other is based on Legacy BIOS. The above script is for UEFI; for Legacy BIOS, simply change lines beginning with UEFI to these

Running the Script

Note: The screenshot below is based on a previous version of the script.

Running the PowerShell commands in one go.

Image

The server would then be rebooted.

Image(1)

When the Windows logo is shown, the ISO image is being transferred. When it has finished the transfer, a spinning circle would be shown under the logo indicating it is loading the Windows PE OS.

Image(2)

We can track the download of Windows PE ISO using netstat and Sysinternals Process Monitor as follows.

Netstat

  • netstat -n 2 | find /i "HP_iLO_IP_addr"

Process Monitor

  • Filter set to: "Path", "Contains", "your_winpe_filename.iso"

Image(3)

The Windows PE is successfully booted up.

Image(4)

Tips and Tricks

The PowerShell command Get-HPiLOPersistenBootOrder below reveals the boot code of each UEFI target in one go

  • Get-HPiLOPersistentBootOrder -Server $iloIP -user $iloUserName -pass $iloPassword | select -ExpandProperty device

Each of them corresponds to the item in the boot order list on iLO web interface, e.g. the first code Boot000D is "iLO Virtual USB 2 : HP iLO Virtual USB CD/DVD ROM" while the third code Boot0008 is "Generic USB Boot".Image(5)

Alternatively, on the boot menu screen (F11) shown during POST, pressing F1 (Help) on each item also reveals the boot item code.

Image(6)

Boot0008 (Generic USB Boot) is recommended over Boot000D (iLO Virtual USB 2 : HP iLO Virtual USB CD/DVD ROM) as the latter is dynamic. It only appears after specifying mounting of the ISO, rebooting the server and getting past POST. When it does not appear, it would return "ERROR: No UEFI Target boot device with the specified BootXXXX name is available."

Image(7)

Persistent boot order is preferred to one-time boot order as the PowerShell results are more consistent. Setting one-time boot order via PowerShell may generate “There is no such EV.” error while host is powered off; setting it via web interface is OK though. Perhaps you might wonder whether it will boot to the ISO every time the server boots? Fortunately no, because we make use of the BOOT_ONCE option of Set-HPiLOVMStatus command to achieve one-time boot (which has nothing to do with boot order). This option mounts the ISO on next boot only and dismounts it automatically on subsequent boots. The VM in the command stands for Virtual Media which corresponds to the below part of the iLO web interface.

As shown, the "Connected" checkbox is only checked on next boot. It is automatically unchecked after subsequent reboots.

Image(8)

Verify the effect of Mount-HPiLOVirtualMedia and Set-HPiLOVMStatus commands using Get-HPiLOVMStatus

  • Get-HPiLOVMStatus -Server $iloIP -user $iloUserName -pass $iloPassword -Device CDROM

Where BOOT_OPTION of -VMBootOption parameter of Set-HPiLOVMStatus can be one of the below:

  • BOOT_ONCE (This should be the case if -VMBootOption is BOOT_ONCE which is option used above in the script.)
  • BOOT_ALWAYS (This should be the case -VMBootOption is CONNECT)
  • NO_BOOT (This should be the case if the Set-HPiLOVMStatus command has not been run, or if -VMBootOption is BOOT_ONCE and the server has already rebooted more than once.)

Image(9)

The VM_APPLET parameter above corresponds to "Image File (CD-ROM/DVD)" checkbox under Virtual Drives menu of the iLO Integrated Remote Console. This option is not available in the iLO PowerShell Cmdlets. Only ImageURL (requires a web server) can be specified.

Image(10)

References

1. Using HP iLO Scripting Tools for Windows

https://kylemurley.wordpress.com/2014/03/04/using-hp-ilo-scripting-tools-for-windows-powershell-mt-getscripting-podcast-powerscripting/

2. HPE Scripting Tools for Windows PowerShell User Guide - iLO Cmdlets [PDF]

http://h20564.www2.hpe.com/hpsc/doc/public/display?docId=c03958206

3. HPE iLO 4 Scripting and Command Line Guide [PDF]

http://h20564.www2.hpe.com/hpsc/doc/public/display?docId=c03334058

4. How to create an ISO image for UEFI platforms for a Windows PE CD-ROM for Windows Server 2008

https://support.microsoft.com/en-us/kb/947024

5. Creating an .iso file from a .wim file

http://www.acronis.com/en-us/support/documentation/ATI2016/index.html#26977.html
http://dl2.acronis.com/u/pdf/ATI2016_userguide_en-US.pdf (Updated)

"To create a bootable media by using a .wim file, you need to convert it to an .iso file first.

To create a PE image (.iso file) from the resulting .wim file:

  1. Select Microsoft Windows AIK ® Windows PE Tools Command Prompt from the Start menu.

    Users of Windows 7 should select Microsoft Windows AIK ® Deployment Tools Command Prompt from the Start menu.

    If you create WinPE 4.0 ISO, select Windows Kits ® Windows ADK ® Deployment and Imaging Tools Environment from the Start menu.

  2. Run the copype.cmd script to create a folder with Windows PE files. For example, from a command prompt, type:

    copype amd64 c:\winpe_x64

  3. Replace the default boot.wim file in your Windows PE folder with the newly created .wim file (for example, AcronisMedia.wim). If the AcronisMedia.wim file is located on c:\, then:

    For WinPE 3.0, type:

    copy c:\AcronisMedia.wim c:\winpe_x64\ISO\sources\boot.wim

    For WinPE 4.0 or WinPE 5.0, type:

    copy "c:\AcronisMedia.wim" c:\winpe_x64\media\sources\boot.wim

  4. Use the Oscdimg tool. To create an .iso file, type:

    oscdimg -n –bc:\winpe_x64\etfsboot.com c:\winpe_x64\ISO c:\winpe_x64\winpe_x64.iso

    Alternatively, to make the media bootable on both BIOS and UEFI computers, type:

    oscdimg -m -o -u2 -udfver102 -bootdata:2#p0,e,bc:\winpe_x64\etfsboot.com#pEF,e,bc:\winpe_x64\efisys.bin c:\winpe_x64\ISO c:\winpe_x64\winpe_x64.iso

  5. Burn the .iso file to a CD using a third-party tool (for example, Nero) and you will have a bootable Windows PE disc with Acronis True Image 2016."

6. Windows boot iso file without press any key

http://serverfault.com/questions/353826/windows-boot-iso-file-without-press-any-key

"It depends on the BIOS. If it is a traditional PC BIOS then the ISO uses the El Torito boot code (etfsboot.com). In this case deleting \boot\bootfix.bin will work.

If it is an EFI BIOS then the ISO should use EFI boot code (efisys.bin). There is also a efisys_noprompt.bin boot code file that can be used when creating the ISO for EFI systems. Use that file instead if you want to eliminate the prompt."

You may bookmark or share this article using the following:

Comments