While we are in the process of migrating to TeamCity for our CI server, we're (sadly) still using CruiseControl.NET for some of our older automated continuous integrations. I have a project that I don't want to have build every time CCNET detects a check in. It's not ideal but this is a special case.

I quickly became bored/frustrated etc. having to open a browser and force a build every time I wanted a new build to kick off. I thought this would be a perfect job to automate using PowerShell.

Below is the script I use to kick off a build of my project. I've made it a bit more generic than the one I use at the office. :)

$projectName = "Test Project"

# Return the project node from the XML 
function GetProject() {
	$doc = New-Object System.Xml.XmlDocument
	$doc.Projects.Project | Where-Object {$_.name -eq $projectName}

#Return the value of the activity element of the project
function GetActivity() {
	$project = GetProject

#Return the lastBuildStatus element of the project
function GetLastBuildStatus() {
	$project = GetProject

#Update this to be the URL to the ViewProjectReport page of the project you are viewing
$result = Invoke-WebRequest "http://SERVER_NAME/server/local/project/$projectName/ViewProjectReport.aspx?ForceBuild=Force" -Method Get

if ($result.StatusCode -eq 200) {
	Write-Host "Build started" -foregroundcolor green
	Start-Sleep -s 10
	$i = 0

	while($i -ne 20) {
		$activity = GetActivity
		Write-Host "Activity: $activity" 
		if ($activity -eq 'Sleeping') {
			Write-Host "Build done" -foregroundcolor green

		Start-Sleep -s 10

	$status = GetLastBuildStatus

	if ($status -eq "Success") {
		Write-Host "Build status: $status" -foregroundcolor green
	} else {
		Write-Host "Build status: $status" -foregroundcolor red

} else {
	Write-Host "NOPE!" -foregroundcolor red

It's been working great and has saved my sanity. Always automate something that you have to do more than twice.