Server Management - Remote Server Management
1752795 Members
5824 Online
108789 Solutions
New Discussion

automate ilo user account on synergy servers

 
Matthew Ingram
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
$Num2=$Num1.Count

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 = @(
'RemoteConsolePriv',
'iLOConfigPriv',
'VirtualMediaPriv',
'UserConfigPriv',
'VirtualPowerAndResetPriv')
$priv = @{}
foreach ($p in $PrivList)
{
$priv.Add($p,$true)
}
$hp = @{}
$hp.Add('LoginName',$ILOuser1)
$hp.Add('Privileges',$priv)
$oem = @{}
$oem.Add('Hp',$hp)
$Headers = @{}
$Headers.Add("UserName" , $ILOuser1)
$Headers.Add("Password" , $ILOpass11)
$Headers.Add('Oem',$oem)

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\1.2.0.0\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\1.2.0.0\HPRESTCmdlets.psm1:1937 char:5
+ $wr = [System.Net.WebRequest]::Create($useUri)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : UriFormatException

 

1 REPLY 1
Sharis
HPE Pro

Re: automate ilo user account on synergy servers

Hello ,

I hope you can use the below script from github.

https://github.com/DungKHoang/Create-iLO-accounts-with-RESTFul-API-from-OneView

Regards,

I am an HPE Employee

Accept or Kudo