All of the URL categories for URL filtering that TMG is aware of are stored in TMG storage at the array level. Here’s an example script that queries for and returns all of the categories. Run the script on any TMG array member.
For Each cat in root.GetContainingArray().RuleElements.UrlCategories
wscript.echo "'" & cat.Name & "' --> " & cat.CategoryID
Alexey Doctorovich, Software Engineer on the TMG Team
(with Nathan Bigman, Content Publishing Manager)
Interesting that you can get all this stuff out via vbscript, but shouldn't this sort of thing be in PowerShell by now?
Does TMG even have a powershell provider?
How to script url override in enterprise? Since previus script has array scope: