Keep inventory of your HPE Moonshot

HPE Moonshot 1500 Chassis

Hosting virtual desktops or apps on physical servers like the HPE Proliant m710x cartridges presents a challenge for server administrators. In virtual environments where hypervisors like VMware’s ESX or Microsoft’s Hyper-V manage XenApp servers, each server is a copy, cloned from a golden image or template. Physical environments are a little bit different as BIOS settings are not contained in a streamed image.

You might have followed my guide on how to configure your HPE Moonshot cartridges using HPE’s ILOrest tool. But how can you verify that after some time all servers still have the desired settings and no admin has tampered with them?

For this purpose I have written a script which exports BIOS settings from all cartridges and creates a nice CSV file, helping you to keep inventory.

# Imports cartridge list and calls function to export BIOS settings
 function Export-CartridgeSettings
 # Path to the Cartridge List

# Import cartridge info from CSV file
 $Cartridges=import-csv $Cartridgelist -Delimiter ";" -Header Servername,Chassis,Port

Foreach($Cartridge in $Cartridges)
 # Call function to export BIOS settings
 Export-BIOSSettings -CartridgeInformation $Cartridge

# Exports BIOS settings with ilorest.exe
function Export-BIOSSettings
 # Servername, chassis and port from the CSV file.

# Create variables from $Cartridgeinformation
 $BIOSfilename = $CartridgeInformation.servername+".json"
 $Chassis = $CartridgeInformation.Chassis
 $Port = $CartridgeInformation.Port
 $ILOurl = $Chassis+":"+$Port
 # Test connectivity to cartridge ILO. For Windows 8 and higher, use 'Test-NetConnection -ComputerName $Chassis -Port $Port' to test the availability of the cartridge
 If((New-Object Net.Sockets.TcpClient $Chassis, $Port).Connected)
 # Export BIOS settings using HPE RESTful Interface Tool
 &"C:\Program Files\Hewlett Packard Enterprise\RESTful Interface Tool\ilorest.exe" save --selector=Bios. -u $Credentials.username -p $credentials.getnetworkcredential().password --url=$ILOurl --filename=$BIOSfilename --logout

# Creates inventory from exported JSON files
function New-CartridgeInventory

 # Cleanup of JSON files

# Cleanup of JSON files

# Find all JSON files as input to inventory
 $JSONfiles = Get-ChildItem *.json
 $CartridgeInventory = @()

Foreach($JSONfile in $JSONfiles)
 # Retrieve information from JSON files and merge 'Comments' section and 'BIOS' section
 $Cartridgeconfig=get-content $JSONfile.Name -raw | convertfrom-json
 $CartridgeComments = $Cartridgeconfig.comments
 $CartridgeBios = $Cartridgeconfig."hpbios.1.2.0"."/rest/v1/systems/1/bios/Settings"

Foreach($NoteProperty in $CartridgeComments | Get-Member -MemberType NoteProperty)
 # Ignore 'SerialNumber' field as it exists in both sections in JSON file
 If($NoteProperty.Name -ne "SerialNumber")
 $CartridgeBios | Add-Member -MemberType NoteProperty -Name $NoteProperty.Name -Value $CartridgeComments.($Noteproperty.Name)

# Add BIOS settings to inventory variable
 $CartridgeInventory += $CartridgeBios

# Export inventory to inventory file
 $cartridgeinventory | Export-Csv -Path $Inventoryfile -UseCulture -NoTypeInformation

# delete all JSON files
 $JSONfiles | Remove-Item


# Set basic information for inventory creation
$Credentials = get-credential
$Cartridgeinputfile = "cartridgelist.csv"
$Cartridgeinventoryfile = "Cartridgeinventory.csv"

# Call export function with desired CSV input file
Export-CartridgeSettings -Cartridgelist $Cartridgeinputfile

# Call function to generate inventory file
New-CartridgeInventory -Inventoryfile $Cartridgeinventoryfile -Cleanup $true

It takes input from a CSV file called ‘cartridgelist.csv’. It is basically a list of all servers, their chassis manager IP as well as their dedicated ILO port:


The result is exported in a CSV file called ‘Cartridgeinventory.csv’.

The script consists of two functions: ‘Export-CartridgeSettings’, which can be used on its own to export all BIOS settings from the servers in the input file to separate JSON files. The second function ‘New-CartridgeInventory’ loops through these JSON files and builds the inventory file. By default, after creating the inventory file all JSON files are deleted. This behaviour can be changed by switching the parameter ‘Cleanup’ from $true to $false.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s