3 Replies Latest reply on Feb 23, 2017 5:13 AM by kwhornlcs

    Which ports need to be open to connect with "Connect-VIServer"?

    enoch85 Novice

      Hi,

       

      I'm backing up my ESXi Host regularly and is running a Powershell script to do so from a Windows VM that acts as my backup VM that handles Veeam and Powershell scripts for backups and such. In front of my whole network (including the VM) I have a firewall that blocks all the traffic except the ports I open. The Windows VM (that hosts the Powershell script) is on 192.168.13.110 and my ESXi Host is on 192.168.1.10.


      When I run "Connect-VIServer 192.168.1.10" from the Windows VM it says I can't connect, if I'm not allowing "any" (*) to my ESXi Host from the Windows VM (192.168.13.110).


      As I want to restrict access and only open the ports needed, I'm wondering - which ports do I need to open to be able to connect to the ESXi Host from the Windows VM and perform a backup? I've tried to open port 443 which allows me to browse the ESXi host, and also 902 for Veeam for function properly, but that's not enough for the script to work. It complains that it can't connect to SSIP.

       

      This is how the scripts look, and it works fyi


      # Variables
      $Server = "192.168.1.10"
      $Folder = "C:\Users\veeam\Nextcloud\ESXi_Backup"
      $FolderOld = "$Folder\Old"
      $Date = Get-Date -f "dd-MM-yyyy"
      $DateOld = "{0:dd-MM-yyyy}" -f (get-date).AddDays(-60)
      $Pass = "SUPERSECRET"
      
      
      # Load PowerCLI
      Invoke-Expression $Folder\Initialize-PowerCLIEnvironment.ps1
      Start-Sleep 3
      Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
      
      
      # Connect to local ESXi Server
      Connect-VIServer $Server -Username root -Password $Pass -Verbose
      
      
      
      # Move existing backup files to the old directory
      Get-ChildItem -Path "$Folder\*.tgz" -Recurse | Move-Item -Destination "$FolderOld\"
      
      
      # Backup ESXi configuration
      Get-VMHost | get-vmhostfirmware -BackupConfiguration -DestinationPath $Folder
      Rename-Item -Force $Folder\configBundle-$Server.tgz -newName $Folder\$Date--$Server.tgz
      
      
      # Delete old bakup
      If (Test-Path $FolderOld\$DateOld--$Server.tgz){
      
      
        Remove-Item $FolderOld\$DateOld--$Server.tgz
      }
      
      
      # Disconnect session vCenter 
      # Backup ESXi configuration
      Get-VMHost | get-vmhostfirmware -BackupConfiguration -DestinationPath $Folder
      Rename-Item -Force $Folder\configBundle-$Server.tgz -newName $Folder\$Date--$Server.tgz
      
      
      # Delete old backup
      If (Test-Path $FolderOld\$DateOld--$Server.tgz){
      
      
        Remove-Item $FolderOld\$DateOld--$Server.tgz
      }
      
      
      # Disconnect session vCenter 
      Disconnect-VIserver -Server $Server -Confirm:$false
      Disconnect-VIserver -Server $Server -Confirm:$false
      

       

      Thanks in advance!

      Daniel