Automation

 View Only
  • 1.  Moving Opaque Network to inventory location

    Posted Apr 21, 2019 03:34 PM

    PowerCLI 11.2 gives us the ability to perform some basic functions on NSX-T opaque networks. I'm trying to find a way to move those opaque networks to a new inventory folder in the Networking view. When I try the Move-Inventory cmdlet, it cannot convert that opaque type to the type it expects. Any of you who have worked with opaque networks in PowerCLI ever tried this?

    $ls = Get-View -ViewType OpaqueNetwork | Where-Object Name -eq <logical_switch_name>

    Move-Inventory -Item $ls -Destination NSX-Test

    Move-Inventory : Cannot bind parameter 'Item'. Cannot convert the "VMware.Vim.OpaqueNetwork" value of type "VMware.Vim.OpaqueNetwork" to type "VMware.VimAutomation.ViCore.Types.V1.Inventory.InventoryItem".

    I'm going to go guess here that this just isn't possible in the current version.



  • 2.  RE: Moving Opaque Network to inventory location

    Posted Apr 21, 2019 06:05 PM

    Try converting that vSphere object $ls to a .Net object.

    Not sure if that is accepted, but worth a try

    $lsNet = Get-VIObjectByVIView -VIView $ls

    Move-Inventory -Item $lsNet -Destination NSX-Test



  • 3.  RE: Moving Opaque Network to inventory location

    Posted Apr 21, 2019 07:37 PM

    That was a good guess, Luc, but when I try that (even with setting a var for Get-View using the MORef) I get a "The object has already been deleted or has not been completely created" error. Since it's possible in the 6.7 HTML5 client to manually move the object to a folder within the Network view, I'm going to fire up Code Capture in the H5 fling to see what .NET it's passing underneath.



  • 4.  RE: Moving Opaque Network to inventory location

    Posted Apr 23, 2019 01:42 PM

    Ok, so here's what Code Capture found and I validated it does work manually if I try it myself. Question is how can I translate this into native cmdlets?

    $list = New-Object VMware.Vim.ManagedObjectReference[] (1)

    $list[0] = New-Object VMware.Vim.ManagedObjectReference

    $list[0].Type = 'OpaqueNetwork'

    $list[0].Value = 'network-o5956'

    $_this = Get-View -Id 'Folder-group-n6002'

    $_this.MoveIntoFolder_Task($list)



  • 5.  RE: Moving Opaque Network to inventory location

    Posted Apr 25, 2019 03:19 PM

    Any tips, LucD​ ?



  • 6.  RE: Moving Opaque Network to inventory location
    Best Answer

    Posted Apr 25, 2019 03:51 PM

    Try like this

    $ls = Get-View -ViewType OpaqueNetwork | Where-Object Name -eq <logical_switch_name>

    $folder = Get-Folder -Name <folder_name>

    $folder.ExtensionData.MoveIntoFolder_Task($ls.MoRef)



  • 7.  RE: Moving Opaque Network to inventory location

    Posted Apr 25, 2019 04:46 PM

    Yep, that was it, thanks. Apparently the MoRef is reported differently depending on the cmdlet, but using that method worked.