This PowerShell script automates the process of connecting to a VMware vCenter server, retrieving a list of ESXi hosts in a specified cluster (or a single host), and running a series of commands on each host to create application accounts using HPE iLO credentials. It is designed for use in HPE/VMware environments where automated account setup and configuration is required.
- Prompts for vCenter, ESXi, and iLO credentials interactively.
- Connects to vCenter using VMware PowerCLI.
- Retrieves all ESXi hosts in a specified cluster or operates on a single ESXi host by IP.
- Automatic Server Generation Detection: Detects whether the server is Gen12 with iLO7 or Gen10/Gen11.
- Uses SSH (via Posh-SSH module) to run commands on each ESXi host based on server generation:
- Creates SUT application account on iLO 7
- Sets iSUT mode to AutoDeploy
- Checks if AMS application account exists before creating
- Starts AMS service using
amsdv
-
Sets iSUT mode to AutoDeploy
-
Starts AMS service
-
Outputs a summary table of results for each command on each host (including server generation).
-
Disconnects from vCenter at the end of execution.
- PowerShell: Run the script in Windows PowerShell with administrative privileges.
- VMware PowerCLI: Must be installed and imported. Download PowerCLI
- Posh-SSH Module: PowerShell SSH module for secure connections to ESXi hosts.
- ESXi/iLO Credentials: You will need valid credentials for vCenter, ESXi root, and iLO.
Run the following command in PowerShell to install the Posh-SSH module:
Install-Module -Name Posh-SSH -Force -Scope CurrentUser- Open PowerShell as Administrator.
- If the script is blocked after downloading, unblock it first:
Unblock-File -Path .\precheck-script\precheck.ps1
- Ensure Posh-SSH module is installed:
If not installed, run:
Get-Module -ListAvailable Posh-SSH
Install-Module -Name Posh-SSH -Force -Scope CurrentUser
- Run the script:
.\precheck-script\precheck.ps1 - Enter the required credentials and target cluster/host when prompted.
-
The script will prompt for:
- vCenter hostname or IP
- vCenter username and password
- ESXi root password
- iLO username and password
- Cluster name or ESXi host IP
-
It will then:
- Connect to vCenter
- Retrieve the list of ESXi hosts
- Detect server generation for each host using
esxcli hardware platform get(Product Name) - Run generation-specific commands on each host via SSH:
For Gen12 (iLO7):
sut appaccount create -u <iLO user> -p <iLO pass>sut -set mode=AutoDeploy/opt/amsdv/bin/amsdCli appaccount check(if account found, skip create)/opt/amsdv/bin/amsdCli appaccount create -u <iLO user> -p <iLO pass>(only if not found)/etc/init.d/amsdv start
For Gen10/Gen11 (iLO5/iLO6):
-
sut -set mode=AutoDeploy -
/etc/init.d/amsd start -
Output a summary table of results with Host, Generation, Command, and Result columns
-
Disconnect from vCenter
Host Gen Cmd Result
---- --- --- ------
192.168.x.x Gen10/11 SUT Set Mode Mode already set to AutoDeploy
192.168.x.x Gen10/11 AMS Start (service started)
192.168.x.y Gen10/11 SUT Set Mode Mode already set to AutoDeploy
192.168.x.y Gen10/11 AMS Start (service started)
- Security Warning: The script converts secure strings to plain text for SSH command execution. Do not use in production without securing credential handling.
- Host Key Handling: The Posh-SSH module automatically accepts host keys with the
-AcceptKey -Forceoptions. - Troubleshooting:
- Ensure PowerCLI and Posh-SSH modules are installed
- Run
Get-Module -ListAvailable Posh-SSHto verify Posh-SSH is installed - Check permissions and network connectivity to vCenter and ESXi hosts
- If SSH connection fails, verify ESXi SSH service is enabled
© Copyright 2026 Hewlett Packard Enterprise Development LP