1-The script function system.opc.getServers() will give you their names, and maybe you can retrieve its endpoint from the taglist
2-It is a lot harder to make the proper connection with a OPC-UA server/client then it is with the device due to the certificates exchange and trust. The designer don’t give an easy way to do so, probably because of the certificates jimbo jambo. They would be some workarounds, but nothing that I recommend for stability sake of your gateway.
Although, I’m curious at to why not have all those connection setup already on your gateway. I would prefer an unused OPC-UA connection then the scripting you are trying to achieve here. Worst case scenario, just toggle the enable propertie of the server.