Issues with WinRM, getting time out. Possible port issue using template

I am having trouble like so many people with getting winRM to work. Im using MWrock templates so in theory it should already be fixed with his scripts that I am using but unfortunately its just timing out…

Here is my json file:

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "vboxmanage": [
        [ "modifyvm", "{{.Name}}", "--memory", "2048" ],
        [ "modifyvm", "{{.Name}}", "--vram", "48" ],
        [ "modifyvm", "{{.Name}}", "--cpus", "2" ]
      ],
      "guest_additions_mode": "attach",
      "guest_os_type": "Windows2016_64",
      "headless": "true",
      "iso_url": "iso/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.iso",
      "iso_checksum": "70721288bbcdfe3239d8f8c0fae55f1f",
      "iso_checksum_type": "md5",
      "communicator": "winrm",
      "winrm_username": "Project",
      "winrm_password": "Project",
      "winrm_timeout": "12h",
      "shutdown_command": "C:/Windows/Panther/Unattend/packer_shutdown.bat",
      "shutdown_timeout": "15m",
      "floppy_files": [
        "answer_files/Autounattend.xml",
        "scripts/winrm.ps1"
      ]
    }
  ],
  "provisioners": [
    {
      "type": "powershell",
      "script": "scripts/windows-updates.ps1",
      "elevated_user": "Project",
      "elevated_password": "Project"
    },
    {
      "type": "windows-restart",
      "restart_timeout": "15m"
    },
    {
      "type": "powershell",
      "execute_command": "powershell -ExecutionPolicy Bypass \"& { {{.Vars}}{{.Path}}; exit $LastExitCode}\"",
      "scripts": [
          "enable-rdp.ps1",
          "guest-tools.ps1"
      ]
  },
    {
      "type": "powershell",
      "script": "scripts/after-reboot.ps1",
      "elevated_user": "Project",
      "elevated_password": "Project"
    },
    {
      "type": "powershell",
      "script": "scripts/cleanup.ps1",
      "elevated_user": "Project",
      "elevated_password": "Project"
    }
  ]
}



**my winrm.ps1:**

    netsh advfirewall firewall add rule name="WinRM-HTTP" dir=in localport=5985 protocol=TCP action=allow
    winrm set winrm/config/service/auth '@{Basic="true"}'
    winrm set winrm/config/service '@{AllowUnencrypted="true"}'
   

and this winrm.ps1 is included in my autounattend file on line 137:

               <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\winrm.ps1</CommandLine>
               <Order>1</Order>

When its running through the build I notice its not using the right port…

==> virtualbox-iso: Pausing after run of step 'StepAttachFloppy'. Press enter to continue. ==> virtualbox-iso: Creating forwarded port mapping for communicator (SSH, WinRM, etc) (host port 3664)

Ive seen other posts about the port but no clear indication of a resolution.

Any help or a point in the right direction would be greatly appreciated.

Resolved by setting up WINRM properly on my local machine…

Follow these troubleshooting steps and then altering the json file to not include port forwarding ad virtualbox doesnt need it: https://www.youtube.com/watch?v=wIhhHk-mIbs&list=PLo_I3XPigb2VqYM_oKE6nS6SzOJYDnFvL&index=3&t=0s

The port that it says its using in cmd when running packer is just the host that its forwarding to the winrm guest port.

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "vm_name": "Evans project",
      "vboxmanage": [
        [ "modifyvm", "{{.Name}}", "--memory", "2048" ],
        [ "modifyvm", "{{.Name}}", "--vram", "48" ],
        [ "modifyvm", "{{.Name}}", "--cpus", "2" ]
      ],
      "guest_additions_mode": "attach",
      "guest_os_type": "Windows2016_64",
      "headless": "false",
      "iso_url": "iso/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.iso",
      "iso_checksum": "70721288bbcdfe3239d8f8c0fae55f1f",
      "iso_checksum_type": "md5",
      "communicator": "winrm",
      "winrm_host": "5985",
      "winrm_username": "Project",
      "winrm_password": "Project",
      "winrm_timeout": "12h",
      "shutdown_command": "C:/Windows/Panther/Unattend/packer_shutdown.bat",
      "shutdown_timeout": "15m",
      "floppy_files": [
        "answer_files/Autounattend.xml",
        "scripts/winrmv2.ps1"
      ]
    }
  ],
  "provisioners": [
    {
      "type": "powershell",
      "scripts": "scripts/windows-updates.ps1",
      "elevated_user": "Project",
      "elevated_password": "Project"
    },
    {
      "type": "windows-restart",
      "restart_timeout": "15m"
    },
    {
      "type": "powershell",
      "execute_command": "powershell -ExecutionPolicy Bypass \"& { {{.Vars}}{{.Path}}; exit $LastExitCode}\"",
      "scripts": [
          "enable-rdp.ps1",
          "guest-tools.ps1"
      ]
    },
    {
      "type": "powershell",
      "script": "scripts/after-reboot.ps1",
      "elevated_user": "Project",
      "elevated_password": "Project"
    },
    {
      "type": "powershell",
      "script": "scripts/cleanup.ps1",
      "elevated_user": "Project",
      "elevated_password": "Project"
    }
  ]
}