Server Management - Remote Server Management
Showing results for 
Search instead for 
Did you mean: 

automate ilo user account on synergy servers

Regular Advisor

automate ilo user account on synergy servers

Do anyone have any working scripts to automate creating ilo user accounts on synergy blades using OneView SSO? I am trying to use the script below but it fails with an error.


#This is first version (1.0) of ILO user add script for all servers throught SSO token with POSH-OV module
#--------------------uncomment this if you want to connect to OV------------
#write-host -ForegroundColor Yellow "You need to autorize at OneView.."
#$OVIP1 = Read-Host 'What is OV IP?'
#$OVuser1 = Read-Host 'What is OV Username?'
#$OVpass1 = Read-Host 'What is OV Username?' -AsSecureString
#$OVpass11 = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($OVpass1))
#Connect-HPOVMgmt -Hostname $OVIP1 -UserName $OVuser1 -Password $OVpass11
#--------------------uncomment this if you want to connect to OV------------

#Disable-HPERedfishCertificateAuthentication #Use this one if you're using new HPERedfishCmdlets module
Disable-HPRESTCertificateAuthentication #Use this one if you're using old HPRestCmdlet module

write-host -ForegroundColor Yellow "Please Choose ILO credentials...."

$ILOuser1 = Read-Host 'What is ILO Username?'
$ILOpass1 = Read-Host 'What is ILO password?' -AsSecureString
$ILOpass11 = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ILOpass1))

$Num1=Get-HPOVServer -Name "SCACP-HPE102, bay 6" | Measure-Object

write-host -ForegroundColor Yellow "You have $Num2 Servers...."
sleep 1

$server1=Get-HPOVServer -Name "SCACP-HPE102, bay 6"
for ($i=0;$i -lt $Num2; $i++) {
$IloSession = Get-HPOVServer -Name $server1[$i].name | Get-HPOVIloSso -IloRestSession
#$UserILO1=Get-HPRESTDataRaw -Href "/rest/v1/AccountService/Accounts" -Session $IloSession

##---User data---
$PrivList = @(
$priv = @{}
foreach ($p in $PrivList)
$hp = @{}
$oem = @{}
$Headers = @{}
$Headers.Add("UserName" , $ILOuser1)
$Headers.Add("Password" , $ILOpass11)

Invoke-HPRESTAction -href "/rest/v1/AccountService/Accounts" -data $headers -Session $IloSession
Disconnect-HPREST -Session $IloSession

Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (400) Bad Request."
At C:\Program Files\WindowsPowerShell\Modules\HPRESTCmdlets\\HPRESTCmdlets.psm1:2038 char:21
+ ... [System.Net.WebResponse] $resp = $httpWebRequest.GetRespo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException

Exception calling "Create" with "1" argument(s): "Invalid URI: The format of the URI could not be determined."
At C:\Program Files\WindowsPowerShell\Modules\HPRESTCmdlets\\HPRESTCmdlets.psm1:1937 char:5
+ $wr = [System.Net.WebRequest]::Create($useUri)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : UriFormatException



Re: automate ilo user account on synergy servers

Hello ,

I hope you can use the below script from github.


I am an HPE Employee

Accept or Kudo