Hi,
I'm not sure how to script this but I assume that you have dashboard access. If you go to the dashboard and click on the question mark in the top right hand corner, then go to "Firewall Info" you can see all of the ports that are being used.
Kathleen
If you found this post helpful, please give it kudos. If my answer solved your problem, click "accept as solution" so that others can benefit from it.