VMware Cloud Community
daphnissov
Immortal
Immortal
Jump to solution

Moving Opaque Network to inventory location

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

6 Replies
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

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.

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

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)

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Any tips, LucD​ ?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

daphnissov
Immortal
Immortal
Jump to solution

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

Reply
0 Kudos