3 Replies Latest reply on Dec 1, 2017 8:35 AM by LucD

    deleting portgroups other than management on VSS_powercli

    jvm2016 Enthusiast

      hello Luc,


      can you check the following code   i want to  compare $pgs (which store all port gruopson vss) to $mgmt(which stores mangement port group on vss)

      however there are unwanted strings  in $mgmt  i.e" key-vim.host.PortGroup-" can you suggest how to use remove or any easy method to get rid of this .



      key-vim.host.PortGroup-VM Network

      key-vim.host.PortGroup-Management Network







      foreach ($esxi in (get-vmhost -location $cluster))


      #get-virtualswitch -vmhost $esxi -standard|select name,vmhost,@{N='portgroups';E={$_.extensiondata.Portgroup -join '|'}}



      $vss=get-virtualswitch -vmhost $esxi -Standard




      $refpg =Get-VirtualPortGroup -Name "Management Network" -vmhost $esxi -standard



      if($pgs -cne "$mgmt")



      write-host "there are portgrups other than managemnet network" -ForegroundColor DarkRed






      write-host "only management network is configure on" $vss.name "on" $esxi.name