Automation

 View Only
  • 1.  Renaming a Virtual Group Name

    Posted Aug 08, 2019 08:32 AM

    Hello All,

    Im trying to rename virtual switches that were previously migrated.

    during migration they were added with a "(1)" in their names.

    Im trying to rename them using PowerCLI 11.2.0.12483638.

    $PortGroups =  Get-VirtualPortGroup -Name "*(1)*" | ? {$_.name -eq "Vlan999 (1)"}

    foreach ($PortGroup in $PortGroups)

    {

        $NewName = $PortGroup.name.Replace(" (1)","-CHI")

        Get-VirtualPortGroup -name $PortGroup.name

        Set-VirtualPortGroup -VirtualPortGroup $PortGroup -name $newname

    }

    while trying to rename a Virtual Port Group, i get the following error:

    Cannot bind parameter 'VirtualPortGroup'

    Cannot convert the "Vlan999 (1)" value of type

    "VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.DistributedPortGroupImpl" to type "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualPortGroup"

    I have even tried without a foreach loop (directly piping the output object from Get-VirtualPortGroup to Set-VirtualPortGroup):

    Get-VirtualPortGroup -Name "Vlan999 (1)" | Set-VirtualPortGroup -Name "VLAN999-CHI"

    But for some reason, Get-VirtualPortGroup is outputting an object which cannot be parsed by Set-VirtualPortGroup:

    Set-VirtualPortGroup : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its

    properties do not match any of the parameters that take pipeline input.

    Anyone has any input on this?

    I can use your help :smileyhappy:

    Thanks!



  • 2.  RE: Renaming a Virtual Group Name
    Best Answer

    Posted Aug 08, 2019 08:40 AM

    You are working with VDS, not VSS.

    Use the Set-VDPortgroup instead.

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

    Was it helpful? Let us know by completing this short survey here.



  • 3.  RE: Renaming a Virtual Group Name

    Posted Aug 08, 2019 09:16 AM

    That was it.

    Thanks!!