Recently I was working with someone helping them automate the final part of their script which was used to deploy new customers as they were on boarded in vCloud Director 5.5, as part of this on boarding they needed to work with the Edge Gateway to add new SNAT and DNAT rules which correspond with the customers IP range.
After some investigation and reading this page I was able to find the basics, after some further testing and internal help I found that there is no way to update a single record so I had to retrieve the existing XML ruleset, add the new entry and then upload it. You can see from the scripts how I do this and if you are feeling adventurous or have the need you could even create some remove- functions!
If you take a look at my Edge Gateway below you can see two existing rules, lets see what the functions do that I created.
Using the PowerCLI functions you can easily list the edge gateway rules using the following:
Creating a new SNAT rule is just as easy with the New-SNATRule function as you can see below:
And also a DNAT Rule with the New-DNATRule function as below:
Hopefully you will find this useful, feedback is of course welcome below in the comments section.