Problem with Remove-VDSwitchVMHost

Hi guys,.

First of all... Here's the PowerCLI version I use:

PowerCLI Version

----------------

VMware vSphere PowerCLI 5.1 Release 2 build 1012425

---------------

Versions of the snap

---------------

VMWare AutoDeploy PowerCLI component 5.1 build 768137

VMWare ImageBuilder PowerCLI component 5.1 build 768137

License of VMware PowerCLI component 5.1 build 669840

VDS's VMware PowerCLI component 5.1 build 1012428

VMware vSphere PowerCLI component 5.1 build 1012428

I'm having a problem with Remove-VDSwitchVMHost which is a bit frustrating. I have a script that I use to rebuild hosts in my environment when we upgrade versions. I recently changed my vDS switches. When the host is rebuilt, there is a phantom entry in the vDS for the old server. For some reason, I can't remove it with Remove-VDSwitchVMHost.

vDS.png

The two hosts in this group appear in the GUI. Esxt21 is the server, I just rebuilt and added to the vCenter.

When you go through PowerCLI, it presents different information:

vDS2.png

When I get home: get-vmhost $vmhost | Get-VDSwitch nothing is returned. If I list the switch first, then get-vmhost, it shows data:

vDS3.png

Get-VDSwitch $vDSName | get-vmhost $vmhost | Delete-VDSwitchVMHost does not seem to work either.

I can delete the host via the interface graphics, but which goes against the idea of a script

Someone had a bit of luck with this?

Thank you

Dan

Got, it works now! Here's the code to work:

$vmhost = "myhostname".

$vDSName = "myvdsname".

$vmhostid = (get-vmhost $vmhost) .extensiondata. Moref.Value
$vDS = (get-VDSwitch $vDSName)
$vDSView = get-view-Id $vDS.id
$vDSView.UpdateViewData)

# - ReconfigureDvs_Task -
$spec = new-Object VMware.Vim.DVSConfigSpec
$spec.configVersion = $vDSView.Config.ConfigVersion
$spec.host = new-Object VMware.Vim.DistributedVirtualSwitchHostMemberConfigSpec [] (1)
$spec.host [0] = new-Object VMware.Vim.DistributedVirtualSwitchHostMemberConfigSpec
$spec.host [0] .operation = 'delete '.
$spec.host [0] .host = new-Object VMware.Vim.ManagedObjectReference
$spec.host [0].host.type = "HostSystem.
$spec.host [0] .host. Value = $vmhostid
_this $ get-view-Id = $vDS.id
_this $. ReconfigureDvs_Task ($spec)

Thanks for your help!

Tags: VMware

Similar Questions

Maybe you are looking for

  • response to screen iPhone touchscreen 6

    Hello First of all, I would like to welcome all users in Apple Support Comunity and I hope I help other users with their problems. But to the point. I m wondering how to make my iPhone more responsible 6 Touch then it is now. Problem is I broke my sc

  • I want Windows 7 return on my Compaq Presario CQ61-312SA!

    I stupidly deleted all partitions on my hard drive, I never created a restore image for my laptop pre-installed Windows 7. I installed Windows XP and I want my Windows 7 32 bit back! I contacted Microsoft and they suggest I have contact the producer

  • Y40 hibernation without giving low battery notification

    I bought laptop 1 year ago. Recently I clean installed windows on my lenovo Y40 10. Laptop will now put into hibernation when the battery reaches 30% without first informing! All my drivers are up to date. I fade this problem what should I do? pls he

  • PCI-6224-88302 during the self-test error code

    Hello I'm having a problem with the auto test my card PCI-6224 in my computer. I am able to run 2 different tables successfully on 2 different computers, but this computer is that it seems to give me trouble. When I open NI MAX to run the test, it gi

  • I can't open anything that uses Windows Explorer...

    I just installed Office 2007 and now I can't open anything that uses Windows Explorer. This includes the trash, all files and folders, same control panel. The only things I seem to be able to run correctly are programs. When I try to open anything, I