Closed ronanmcallister closed 6 years ago
You would use Get-HPOVScope
to get the scope you want to perform operations with. Within that [HPOneView.Appliance.Scope]
object, there is a Members
property that contains the resources that are associated with that scope. Within those resources is an Uri
property which you can then get the server object.
The following should help you with what you're trying to do.
# Get Scope resource from API
$Scope = Get-HPOVScope -Name ScopeName -ErrorAction Stop
# Export Scope "members" property for reference later
$scope.Members | Select -Property @{Name=’ScopeName’;Expression={$Scope.Name}},@{Name="Name"; Expr
ession={$_.Name}},@{Name = "Type"; Expression = {$_.Type}},@{Name = "Uri"; Expression = {$_.Uri}},@{Name = "ResourceName
"; Expression = { (Send-HPOVRequest $_.uri).name }} | Export-Csv c:\temp\scope_members.csv -NoTypeInformation
# Validate the CSV was created
Test-Path c:\temp\scope_members.csv
# Examine the CSV file. This should open with your workbook/worksheet editor, or another editor if .csv is registered to a specific application on your PC.
& c:\temp\scope_members.csv
# Remove the server resource
Get-HPOVServer -Name "Server Name" -ErrorAction Stop | Remove-HPOVServer -Confirm:$false | Wait-HPOVTaskComplete
# Add the server back, and specify the scope to add it to
Add-HPOVServer -Computername "Server Address" -Credential $MyiLOCreds -Scope $Scope
# Validate the resource was added to the scope
(Get-HPOVScope -Name ScopeName).Members | ? Name -eq "Server Address"
And the reason why the Export-CSV
code is long is due to the Cmdlet not expanding sub properties. So, you have to use an Expression to include the Scope name. I might look at implementing an .Export()
method to the HPOneView.Appliance.Scope
class to help with this type of operation in the future.
Closing due to no further activity.
Please fill in as much information as possible to help resolve your issue.
Expected Behavior
Any ideas/examples on how to perform the following is appreciated. OneView POSH v 4.0.1672.1789, OneView 4.00.09.
I apologize in advance as this is probably a very basic question!
We have hundreds of HPE DL* iLO4/iLO5 servers in OneView (NO other HPE equipment such as Chassis/Blades, storage) -- currently none have assigned Profiles, some are Monitored, some Managed however, each server has multiple Scopes per DL Server HW [0..33 Scopes per Server HW).
We have the need to remove all Server HW above 250 of them, to test an issue we have escalated with HPE OneView SCOM R&D. Here's what I hope to accomplish:
1/ Save all Server HW, with associated scopes (to be "restored" in #4). 2/ Delete the server HW "saved" in #1 (leaving 249 in Server HW in OneView). [ we test our issue here -- has to do with RabbitMQ and Certificates/.NET ] 3/ Add all Server HW back each Server HW we deleted in #2 4/ Associate any/all of 0..33 HPOVScope(s) with each Server HW getting us back to where we were originally.
I'm using relatively simple "one liner" OneView POSH to date due to time constraints; I understand the basics, on how to Add/Remove servers and associate Scopes with Servers, how to show our list of Scopes running the Cmdlets...
The part I'm having a problem with is how I can programmatically fetch all of the Scopes associated with each individual Server HW (DL Server); Get-HPOVProfile which returns an HPOneView.Appliance.ScopeCollection and Get-HPOVServer which returns HPOneView.ServerHardware [System.Management.Automation.PSCustomObject]
Any high-level pseudo code is appreciated if working OneView POSH examples are not available.
I thought about using PowerShell Compare-Object, not getting much traction with this.
Actual Behavior
Steps to reproduce
Sorry I have no code to show at the moment.
Version Information
HPE OneView PowerShell Library Version (
Get-HPOVVersion
or$PSLibraryVersion
):4.0.1672.1789
HPE OneView Appliance Version (
Get-HPOVVersion -ApplianceVer
):4.00.09.345092.00
Output from
$PSVersionTable
on your Windows Host:Name Value
PSVersion 5.1.16299.492
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.492
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1