VMware Cloud Community
plaman
Enthusiast
Enthusiast
Jump to solution

PortGroup is not accessible from this host

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 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
10 Replies
fabio1975
Commander
Commander
Jump to solution

Ciao 

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

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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? 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
plaman
Enthusiast
Enthusiast
Jump to solution

plaman_0-1621314245139.png

 

plaman_1-1621314352286.png

your thoughts please 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
plaman
Enthusiast
Enthusiast
Jump to solution

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}

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
plaman
Enthusiast
Enthusiast
Jump to solution

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 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
plaman
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos