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?
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.
Try like this
$folder = Get-Folder -Name <folder_name>
$folder.ExtensionData.MoveIntoFolder_Task($ls.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try converting that vSphere object $ls to a .Net object.
Not sure if that is accepted, but worth a try
Move-Inventory -Item $lsNet -Destination NSX-Test
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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[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)
Any tips, LucD ?
Try like this
$folder = Get-Folder -Name <folder_name>
$folder.ExtensionData.MoveIntoFolder_Task($ls.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yep, that was it, thanks. Apparently the MoRef is reported differently depending on the cmdlet, but using that method worked.