Automation

 View Only
  • 1.  PortGroup is not accessible from this host

    Posted May 17, 2021 08:39 AM

    I have a fully automated script that has been working for the past few months, with no issues, but now when I am trying to deploy a new VM i receive an error message "PortGroup is not accessible from this host "even though the portgroup is available on the host  

    I am using powercli 12.2.0 build 17538434

    any suggestions would be appreciated 



  • 2.  RE: PortGroup is not accessible from this host

    Posted May 17, 2021 09:31 AM

    Ciao 

    Haven't you run out of ports allocated for the PortGroup? Is The PortGroup  Elastic or Fixed?



  • 3.  RE: PortGroup is not accessible from this host

    Posted May 17, 2021 09:55 AM

    Without seeing your actual code, it is impossible to determine what goes wrong.
    Does a 


    Get-VirtualPortgroup -Name <your-pg> -VMHost <your-ESXi-node>  -Standard

    return anything? 



  • 4.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 05:06 AM

    plaman_0-1621314245139.png

     

    plaman_1-1621314352286.png

    your thoughts please 



  • 5.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 05:39 AM

    That is not the same error you started this thread with?

    Btw, a screenshot is not very helpful when sharing code, I'm really not going to type in that code from a screenshot.



  • 6.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 06:09 AM

    Message classified as External Non-Confidential

     

     $linuxSpec = New-OSCustomizationSpec -OSType Linux -Name $VMName -DnsServer $DNS1,$DNS2 -DnsSuffix $Domain -Domain $Domain -Type Persistent -NamingScheme fixed -NamingPrefix $ServerName -Server $vcentre

                                   

                    # $linuxSpec = New-OSCustomizationSpec -OSType Linux -Name $VMName -Domain $Domain -DnsSuffix $Domain -Type Persistent -DnsServer $DNS1,$DNS2 -NamingScheme fixed -NamingPrefix $NetBios

                   

                     write-host "CREATING NEW CUSTOMISATIONS NIC MAPPING SPECIFICATION FOR YOUR VM" -ForegroundColor Yellow          

                    

                    Get-OSCustomizationNicMapping $linuxSpec|Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $IP -SubnetMask $SubNetMask -DefaultGateway $Gateway  -Server $vcentre

                     write-host "Passed point1 Get-OSCustomizationNicMapping"

                   New-VM -Name $VMname -Template $OS -Location $Application  -VMHost  $HostName -Portgroup  (Get-VirtualPortGroup -Name $PortGroup -VMHost $HostName).Name -Datastore $Datastore -Server $vcentre -OSCustomizationSpec $linuxSpec -ErrorAction Stop

                     write-host "Passed point2 New-VM"

                    Start-VM  $VMname |Wait-Tools -TimeoutSeconds 180

                    write-host "Passed point3 Start-VM "

                  #Check if the deploymnet is completed

      $CustomisationStatus= Check-Customisation -VMname $VMName

       write-host "the CustomisationStatus is $CustomisationStatus"

      if ($CustomisationStatus -notlike ("SUCCESSFUL")) {

      write-host "Send email the server $VMName  Customisation has failed"}

    #check the vm

      $PingWaitCounter=[int]"0"

    do {$VMReady=Check-VM-Ready-Status -vmname $vmname -IP $IP

             Start-Sleep -Seconds 2

             $PingWaitCounter = $PingWaitCounter +2

             Write-Host "WAITING FOR SERVER TO RESPOND, NOW WAITING $PingWaitCounter" -ForegroundColor Red

            } Until ((($VMReady[0] -eq "OK") -and ($VMReady[1]-eq"Success") -and ($VMReady[2] -eq "Started")) -or ($PingWaitCounter -eq "100"))

          if ($PingWaitCounter -eq "100") {

         Write-Host "Need to send email, the server $VMName is not responding to ping, please check the Status " -ForegroundColor Red }

      #server will restart automatically one more time for the Customisation to take effect

    write-host "passed this point" -ForegroundColor Yellow

        do{

         $VMReady=Check-VM-Ready-Status -vmname $vmname -IP $IP

         Start-Sleep -Seconds 2

         $WaitCounter=$WaitCounter+2

         }Until   ((($VMReady[0] -eq "OK") -and ($VMReady[1] -eq "Success")) -or ($WaitCounter -eq "100"))  

          

          if (($VMReady[0]  -eq "OK") -and ($VMReady[1] -eq "Success") )

          {write-host "The $vmname server is ready to accept commands" -ForegroundColor Green}

     



  • 7.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 06:46 AM

    Which error are you getting?
    You have mentioned two different errors.



  • 8.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 06:51 AM

    with the above code, i am getting the "could not find virtualportgroupbase with name"

    if I change the -portgroup to "-Portgroup  (get-vdportgroup -Name $PortGroup).Name " I get the error in titled in the thread 



  • 9.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 07:46 AM

    Try changing the Portgroup parameter to

    -Portgroup  (Get-VDPortgroup -Name $PortGroup)

    passing the actual object and not the string with the name.

    Also, make sure that the ESXi node in $Hostname is added to the VDS that contains the portgroup.



  • 10.  RE: PortGroup is not accessible from this host

    Posted May 18, 2021 09:06 AM

    using the above command will result “PortGroup is not accessible from this host".

    before I select the $hostname I check if the host has access to that port group.

    we just added another cluster to the same vcentre using the same port group names. hence when I run the   

    -Portgroup  (Get-VDPortgroup -Name $PortGroup)

    The result will return the 2 protogroups with the same name



  • 11.  RE: PortGroup is not accessible from this host
    Best Answer

    Posted May 18, 2021 09:17 AM

    Then you will have to explicitly select the correct VDS.

    -Portgroup  (Get-VDSwitch -Name <VDS-name> -VMHost <esx-name> | Get-VDPortgroup -Name $PortGroup)

    Btw, the info that you have 2 portgroups with the same name would have helped at the beginning of this thread