HewlettPackard / POSH-HPEOneView

PowerShell language bindings library for HPE OneView.
http://hewlettpackard.github.io/POSH-HPEOneView/
125 stars 52 forks source link

Add Resource to Scope #646

Closed DungKHoang closed 11 months ago

DungKHoang commented 1 year ago

Expected Behavior

Add server hardware to scope using Add-OVresourceToScope

Actual Behavior

Error in script and no resource added

Steps to reproduce


$server_list = @(

    @{
        "Serial_Number"  = '' ;
        Name            = '172.18.31.13';   
        "IP address"    = '172.18.31.13';   
        Scopes          = 'Nodes 03'
    }
)

Connect-OVMgmt -Hostname 172.18.31.84 -username administrator -Password *******

foreach ($s in $server_list)
{
    $_sc            = $s.scopes.trim()
    $sName          = $s.Name
    $sIP            = $s.'IP address'

    $scope          = get-OVScope | where name -eq  $_sc
    if ($null -eq  $scope)
    {   
        $_desc      = "$_sc of all Cohesity Clusters"           # Nodes xx of all Cohesity Clusters
        $scope      = new-OVScope -name $_sc -description $_desc | Out-Null
    }

    if ($null -eq (Get-OVServer | where name -eq $sName))
    {
        # Add Server and assign to the corresponding scope

        Add-OVServer -Hostname $sIP -Credential $iLO_cred -LicensingIntent OneView -Scope $scope
    }
    else 
    {
        # Assign server to the corresponding scope ONLY

        $scope | Add-OVResourceToScope -inputobject $s
    }

} 

Disconnect-OVMgmt

Version Information

HPE OneView PowerShell Library Version (Get-HPOVVersion or $PSLibraryVersion): 8.0.3528.2178 HPE OneView Appliance Version (Get-HPOVVersion -ApplianceVer): 8.40.00.480384.00 Output from $PSVersionTable on your Windows Host:

# Output from $PSVersionTable  : 7.3.5

2307240448_HPEOV_transcript.log

ChrisLynchHPE commented 11 months ago

I'm sorry, but I don't see the issue here. Can you be more specific on what exactly is happening?

DungKHoang commented 11 months ago

Steps to reproduce: $scope = new-OVScope -name test $s = get-OVServer -name '0000A66101, Bay 1' 2309250659_HPEOV_transcript.log

$scope | add-OVResourcetoScope -inputobject $s

DungKHoang commented 11 months ago

Use wrong library. Closed