Skip Ribbon Commands
Skip to main content

My blog

:

Home
July 08
TunnelPortRanges and OverloadDefinitions

Just the other day, someone desired to add a tunnelport range to the TMG proxy, but did not know how to.
I found out I needed to set this straight in the TMG array configuration. Luckily there are some tools available which can make the required change in the TMG array configuration. But it is way more fun doing it yourself.
Actually it was quite simple!

First start a PowerShell session and connect to the TMG array configuration (also works with ISA).

$tmg = new-object -comobject fpc.root
$a = $tmg.Arrays | ? { $_.name -eq "ArrayName"}

Then "browse to the WebProxy TunnelportRanges" using [Tab] and ".", add the configuration and save.

$a.ArrayPolicy.WebProxy.TunnelPortRanges.AddRange("SSL 8443",8443,8443)
$a.ArrayPolicy.WebProxy.TunnelPortRanges.save()

Check the current configuration.

PS> $a.ArrayPolicy.WebProxy.TunnelPortRanges | ft –a

Name     TunnelLowPort TunnelHighPort
---      ------------- --------------
NNTP               563            563
SSL                443            443
SSL 8443          8443           8443

         

You also check the "Change Tracking" in TMG to see if the TunnelPortRange has been added.

 

I got the question how I found out the correct input for the .AddRange. Although sometimes you got to keep your colleagues in the dark but this one is actually quite easy. It's called the "OverloadDefinitions", and it works most of the time:

PS> $a.ArrayPolicy.WebProxy.TunnelPortRanges.AddRange.OverloadDefinitions
IFPCTunnelPortRange AddRange (string, int, int)

 Just add .overloaddefinitions after a method and it returns some info, some info is better than others. In this case it requires a text input, a number and another number. At least you know the correct input format and it is not hard to figure out the right context of this values.

Easy isn't it?

         

...and then the other question of the day. How to remove a TunnelPortRange, because someone made a typing error.

Luckily there is a $a.ArrayPolicy.WebProxy.TunnelPortRanges.remove("Name of range to remove") and .save() it again to remove the TunnelPortRange.

July 11
Running “cleanmgr.exe” on server 2008

When running out of disk space on Server 2008 you might want to run "cleanmgr.exe". But it's not there on Server 2008.

When searching the internet for more info, all returned answers said I'd have to install the "Desktop experience" feature. But I certainly do not want to enable the "desktop experience" feature on a production server. I do not need Windows Mediaplayer, Photoviewer, etc.

I copied "cleanmgr.exe" from a server where the desktop experience feature was enabled to a server which did not have that feature enabled (to the %Systemroot%\System32 folder) and executed the .exe. Nothing happened. Then I searched for a missing .dll but none existed/worked.

Back tot the server with the "Desktop Experience' feature enabled, ran "Process Explorer" to search for dependencies of "cleanmgr.exe"

And there it is, %systemroot%\System32\en-US\Cleanmgr.exe.mui" among other *.mui's. Copied "cleanmgr.exe.mui" to the other server (with the already existing "cleanmgr.exe"), started "cleanmgr.exe again, and guess what:

Finally, cleanmgr without installing the "Desktop Experience" feature on server 2008.

May 24
WSS v3 Backup retention script

After setting up STSADM.exe to backup my WSS v.3 sites the backup directory did grow daily.

 I could not find any way to set some sort of retention on these backups, and got tired of deleting the backups and adjusting the spbrtoc.xml manually. So I wrote my own script.

 As a real PowerShell addict this problem had to be solved with PowerShell. Here's the script.

# Clean-up (old) backup files created by WSS v3 (STSADM.EXE)
# Created by Marco
# Tested with PowerShell RTM v1.0

# Location of spbrtoc.xml
$spbrtoc = "E:\Backup\Sharepoint\spbrtoc.xml"

# Days of backup that will be remaining after backup cleanup.
$days = 5

# Import the Sharepoint backup report xml file
[xml]$sp = gc $spbrtoc

# Find the old backups in spbrtoc.xml
$old = $sp.SPBackupRestoreHistory.SPHistoryObject | ? { $_.SPStartTime -lt ((get-date).adddays(-$days)) }
if ($old -eq $Null) { write-host "No reports of backups older than $days days found in spbrtoc.xml.`nspbrtoc.xml isn't changed and no files are removed.`n" ; break}

# Delete the old backups from the Sharepoint backup report xml file
$old | % { $sp.SPBackupRestoreHistory.RemoveChild($_) }

# Delete the physical folders in which the old backups were located
$old | % { Remove-Item $_.SPBackupDirectory -Recurse }

# Save the new Sharepoint backup report xml file
$sp.Save($spbrtoc)
Write-host "Backup(s) entries older than $days days are removed from spbrtoc.xml and harddisk."

 This script does:

  • queries the spbrtoc.xml and finds all backups
  • deletes old backup entries from spbrtoc.xml
  • deletes the old backup files from disc
  • saves the updated spbrtoc.xml.

The result:



Just schedule this script to run after the backup has been made and no more manual deletion of the backup files is needed.

As a real IT Pro, you can now put your feet on the table and drink a relaxing cup of coffee. (Well at least until your boss finds you in this way…)

 

 About this blog

 
About this blog

Welcome to my blog.

Just some blogs about my adventures to keep things running...