Agree, that would be nice, we already have that code too, see https://github.com/NServiceBus/NServiceBus/blob/develop/src/PowerShell/NServiceBus.PowerShell/PortUtils.cs