Archive

Archive for the ‘Scripting’ Category

Using PowerShell to Determine Forefront TMG Build Number

December 14, 2015 Comments off

Using PowerShell to Determine Forefront TMG Build NumberIdentifying the current build number of your Forefront TMG 2010 installation is critically important when making changes or updates to the system. It is generally recommended that all TMG firewalls be on the same release, so having this information is essential. Many TMG administrators use the TMG management console to gather this information, but I can tell you based on experience that this is not always the most accurate method to use.

I much prefer to gather this information programmatically at the command line. In the past I’ve written about using VBScript to do this, but it’s almost 2016 now and we really should be using PowerShell whenever possible. To that end, here are a few lines of PowerShell code you can use to accurately determine which version and build number your TMG firewall is currently running.

$FPC = New-Object -ComObject FPC.Root
$Server = $FPC.GetContainingServer()
$Server.ProductVersion

Using PowerShell to Determine Forefront TMG Build Number

If you’ve done any work at all with VBScript and the TMG’s FPC COM object, you’ll no doubt be able to convert some of your existing scripts to PowerShell. Also, PowerShell, with its tab auto completion, is much more discoverable than using VBScript with COM, so I’m sure you’ll be able to do a lot more with TMG using PowerShell.

Enjoy!

Enable Authentication for SafeSearch Enforcement Rule in Forefront TMG 2010

February 28, 2013 4 comments

SafeSearch enforcement in Forefront TMG 2010 is a simple and effective way to prevent users on your network from accessing explicit adult content via popular search engines. Enabling SafeSearch enforcement is accomplished by opening the Forefront TMG 2010 management console, highlighting the Web Access Policy node in the navigation tree, clicking the Configure SafeSearch link in the Tasks pane and selecting the option to Enable SafeSearch.

Forefront TMG 2010 Safe Search Enforcement

When SafeSearch is enabled a rule is created that grants access to all users from the Internal network to all sites in the Search Engines category.

Forefront TMG 2010 Safe Search

Effectively this grants unauthenticated access to many search engines including Bing, Google, and Yahoo. This level of access is quite broad and enables anonymous users to access quite a bit of content, which might not be desirable in some environments. It is not possible to change the users in the GUI either, unfortunately. However, it can be changed programmatically using COM and VBscript. For example, the following code will change the users from All Users to All Authenticated Users.

Dim Root, Array, Rule
Set Root = CreateObject("FPC.Root")
Set Array = Root.GetContainingArray()
Set Rule = Array.ArrayPolicy.PolicyRules("SafeSearch")
Rule.AccessProperties.UserSets.Add "All Authenticated Users", fpcInclude
Rule.AccessProperties.UserSets.RemoveSpecified "All Users"
Array.Save
Array.WaitForReload

Important Note: This change is not officially supported by Microsoft. If you make this change it may potentially cause other issues, so please proceed with caution.

Once the script has completed the SafeSearch rule will now apply to All Authenticated Users and prevent unwanted anonymous access to web sites categorized as Search Engines.

Forefront TMG 2010 Safe Search

How to Determine TMG Version

October 11, 2010 Comments off

Recently Tarek Majdalani, one of my fellow Forefront Edge Security MVPs, published an informative article detailing several ways to determine which version of TMG is installed. One additional method you can use to determine the version of TMG you are running is by using COM. The VBScript code looks like this:

Option Explicit

Dim Root, Server

Set Root = CreateObject("FPC.Root")
Set Server = Root.GetContainingServer

WScript.Echo Server.ProductVersion

Set Server = Nothing
Set Root = Nothing

Copy the code above and save it in a file with a .vbs extension, or download the script file here.

You can execute the script from the command line using cscript.exe using the following syntax:

cscript.exe <path_to_script_file>

The output of the command includes the TMG version and build number information.

You can also double-click the script file in the GUI and a Windows message box will appear with the TMG version and build number information.