MSBuild and 7Zip SFX

The following allows you to package up your build output into a SFX file with custom properties that appear when someone right clicks the SFX and chooses properties.

Useful if you need to create a zip that can be signed but want your company/product information to appear on the SFX.EXE.

Read More

Update sshd_config to use Protocol 2

Had to write an script to update SSHD to only use protocol 2 without changing any of the other settings, to be deployed via BMC Bladelogic (horrible horrible tool), but you work with what you have. The script should work across Linux, AIX and Solaris.

$> update [1|2]
$> rollback

Read More

Convert XML and XSL to HTML

Just a quickie. I have a script that outputs an XML file and I use an XSL file to display it but Management wanted HTML files, the thought of having to re-code the output was disheartening to say the least. I then came across “msxsl.exe” it’s a Microsoft tool that takes a XML file and a XSL file and then generates the resultant rendered output in HTML.

msxsl.exe -o

TFS queue build from powershell

I was doing some testing on TFS and got fed up queuing new builds via right-click -> queue new build -> ok. So here is a powershell script that can be used to kick off a build.

I’ve included some extra assemblies that don’t need to be used as I have other functions that do use them in the same module file. example useage below

Queue-TFSBuild -TFSServer http://tfsserver:8080/tfs/col -Project Project1 -Definition DailyBuild

$arrAssemblies = @(
Foreach ($assembly in $arrAssemblies) {
Remove-Variable assembly, arrAssemblies

Function Queue-TFSBuild {
    Param (

    Process {
        [Microsoft.TeamFoundation.Client.TfsTeamProjectCollection]$tfsc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($TFSServer)
        $IBS = [Microsoft.TeamFoundation.Build.Client.IBuildServer]

        [Microsoft.TeamFoundation.Build.Client.IBuildServer] $buildserver = $tfsc.GetService($IBS)
        [Microsoft.TeamFoundation.Build.Client.IBuildDefinition] $BuildDef = $buildserver.GetBuildDefinition($Project,$Definition)
        [Microsoft.TeamFoundation.Build.Client.IBuildRequest] $BuildReq = $BuildDef.CreateBuildRequest();

Get Numeric Values from an Enum in powershell

I needed to get the values for a enum in order to generate the correct flags for a function call here’s how to do it.

[Enum]::GetValues() will return a list of all the values

::.value__ will return the numeric value enum

[Enum]::GetValues([Microsoft.TeamFoundation.Build.Client.BuildStatus]) | foreach {
$Name = $_
$Value = ([Microsoft.TeamFoundation.Build.Client.BuildStatus]::$_).value__
Write-Output "$Name = $Value"

TFS Warehouse Cube Status via SOAP and Powershell

Well I’ve just been put in charge of managing our TFS infrastructure so here is the first of hopefully many posts around automating and managing TFS.

The attached script runs a SOAP query against the TFS Warehouse Cube and returns the jobs and their status and then either generates an HTML file or sends an HTML email with the results.

I recommend creating a directory called Scripts on the C:\ drive and setting the permissions so that only the System Administrator & User the script runs as can access the contents of the directory.

Read More

Scripted checking of SCCM Backups

This is a script that parses the smsbkup.log and outputs results (in html) and the relevant portions of the file to the specified folder. The idea being that the with a small bit of tweaking you could have the report hosted on  a webserver to check or emailed (there will be a post on emailing in Powershell later) to you.

This is best run from the central primary under credentials that have access to the other sites.

Note: The script requires UNC paths for the $fpath variable as it is expecting be be run remotely.

Note2: This script was written for SCCM 2007 and not for SCCM 2012, however thanks to one of my readers, Satish, the following should fix that:
if ($content | where {$_ -like "Backup task completed successfully*"}) {
if ($content | where{$_ -like "*SQL Backup task completed successfully*"}) {

Potential Dates issues with SCCM 2012 R2. Thanks to Marius for the update.
$cdate = $cdate.adddays($days) | get-date -format “ddd MMM dd”
to (this is probably US specific and will probably vary depending on locale)
$cdate = $cdate.adddays($days) | get-date -format “MM-dd-yyyy”

Read More

Network Diags

One of my users was complaining of “slow vm performance over the network”, so I requested a few simple diags including a traceroute from his machine to the vm instead I got a traceroute from the VM to the VM. So I decided that clearly I was asking too much from the user and threw the following batch file together (I may rewrite it in powershell for fun later).

Read More


This is a function that allows you to clone a VM from a specified snapshot. The only way to do this in the UI would be to take a snapshot of the current state, revert to the one you wish to clone, clone, revert to latest snapshot and then delete latest snapshot. As you can see that is time consuming and takes numerous mouse clicks.

I recommend adding this function to your powershell profile so you always have access to it.

As always feel free to comment.

Read More