HewlettPackard / POSH-HPEOneView

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

ConvertTo-OVPowerShellscript error on server profile with Network Set in profile connection #633

Open DungKHoang opened 1 year ago

DungKHoang commented 1 year ago

Expected Behavior

Get-OVServerprofile | Convertto-OVPOwershell script genrates error on network set attached to profile connec tion See attached file from get-OVCommandTrace

Version Information

HPE OneView PowerShell Library Version (Get-HPOVVersion or $PSLibraryVersion): HPEOneView.660 HPE OneView Appliance Version (Get-HPOVVersion -ApplianceVer): OneView 6.6

2301271509_HPEOV_transcript.log

odesaphy commented 1 year ago

Hello Dung The quick fix I'm using : Generate-NetConnection-Script function (around line 15808 in the 6.60.3332.3428 library module file):

                    $netName     = Get-NamefromUri -Uri $netUri
                    if ($netUri.StartsWith("/rest/network-sets")) {
                        $thisNetwork = Get-OVNetworkSet -Name $netName -ErrorAction Stop
                    } else {
                        $thisNetwork = Get-OVNetwork -Type $ConnType -Name $netName -ErrorAction Stop
                    }

Olivier

ChrisLynchHPE commented 1 year ago

This can be simplified with the following code instead:

                Try
                {

                    # Just get the whole object in order to get the type and name
                    $thisNetwork = Send-OVRequest -Uri $netUri

                    $netName     = $thisNetwork.name

                }

                Catch
                {

                    $PSCmdlet.ThrowTerminatingError($_)

                }

Which is what the library will use to fix this issue.