Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 231085

Re: Anyone know a way to move a vds to a network folder?

$
0
0

You can use the MoveIntoFolder_Task method found on the folder object.

 

http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.Folder.html

 

If you have any port groups attached to the dvs they will also need to be moved as well. Here is a sample script that I wrote and tested with one dvs and two port groups. I am sure there is a more elegant approach but this should get the job done.

 

$folder = Get-Folder -Type Network -Name folderName | Get-View
$dvs = Get-VirtualSwitch -Name dvsName
$dvPGs = $dvs | Get-VirtualPortGroup
$count = $dvs.count + $dvPGs.count
$list = New-Object VMware.Vim.ManagedObjectReference[] ($count)
$list[0] = New-Object VMware.Vim.ManagedObjectReference
$list[0].type = $dvs.Extensiondata.MoRef.Type
$list[0].value = $dvs.Extensiondata.MoRef.Value
$dvPgCount = 1
foreach ($dvPg in $dvPgs) {    $list[$dvPgCount] = New-Object VMware.Vim.ManagedObjectReference    $list[$dvPgCount].type = $dvPg.Extensiondata.MoRef.Type    $list[$dvPgCount].value = $dvPg.Extensiondata.MoRef.Value    $dvPgCount++
}
$folder.MoveIntoFolder_Task($list)

Viewing all articles
Browse latest Browse all 231085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>