HPE OneView
1833467 Members
2553 Online
110052 Solutions
New Discussion

Oneview server discovery script with Powershell cmdlet

 
Ckirim
Senior Member

Oneview server discovery script with Powershell cmdlet

Hello Dear,

I'm trying to scripting multiple servers discovery (add") through the Oneview PowerShell cmdlet.  Within in script, I am using the following rest command for multiple servers add;

$discover = Send-OVRequest -Uri "/rest/server-hardware/discovery" -Method Post -Body $body

As body;

$body = @{
"mpHostsAndRanges" = "[10.254.254.2 - 10.254.254.50}"
"username" = "hpeadmin"
"password" = "admin123"
"licensingIntent" = "OneViewStandard"
"configurationState" = "Monitored"
}

but of course,  for the parameter "mpHostsAndRanges" , it gives me "string" instead "array."

$body.mpHostsAndRanges.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object

as a workaround, I can define an array with a for loop to get my IP range. ( but I do not want to prefer this method)

$array = @()

for ($i= 1 ; $i -lt 50 ; $i++) {

$array += @("10.254.254.$i")

}

do you have any idea about this issue?  how can I define the array within the $body parameter? 

Regards,

Cihat 

 

 

 

 

1 REPLY 1
MV3
HPE Pro

Re: Oneview server discovery script with Powershell cmdlet

Hello

 

Please check the below link if that helps you.

 

Link : https://github.com/HewlettPackard/POSH-HPEOneView/issues/438

 

Cheers...



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo