Skip to content

Instantly share code, notes, and snippets.

View jstangroome's full-sized avatar

Jason Stangroome jstangroome

View GitHub Profile
@jstangroome
jstangroome / LabDefaultTemplate.xaml
Created September 23, 2010 08:10
Fail a Lab build when the environment is in use
<Activity mc:Ignorable="sad" x:Class="TfsBuild.Process" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:this="clr-namespace:TfsBuild;" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mt="clr-namespace:Microsoft.TeamFoundation;assembly=Microsoft.TeamFoundation.Common" xmlns:mtbc="clr-namespace:Microsoft.TeamFoundation.Build.Client;assembly=Microsoft.TeamFoundation.Build.Client" xmlns:mtbco="clr-namespace:Microsoft.TeamFoundation.Build.Common;assembly=Microsoft.TeamFoundation.Build.Common" xmlns:mtbp="clr-namespace:Microsoft.TeamFoundation.Build.ProcessComponents;assembly=Microsoft.TeamFoundation.Build.ProcessComponents" xmlns:mtbw="clr-namespace:Microsoft.TeamFoundation.Build.Workflow;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtbws="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Services;assembly=Microsoft.TeamFou
@jstangroome
jstangroome / gist:621345
Created October 11, 2010 22:32
PowerShell script to test if ASP.NET padding security patch is applied
Set-StrictMode -Version Latest
[Reflection.Assembly]::Load('System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | Out-Null
[System.Web.Configuration.MachineKeySection].GetMethods('NonPublic, Public, Static') |
Where-Object {
$LastParameter = $_.GetParameters() | Select-Object -Last 1
$_.Name -eq 'EncryptOrDecryptData' -and
$LastParameter -ne $null -and
$LastParameter.ParameterType -eq [bool] -and
@jstangroome
jstangroome / msbuild-hardlink.cmd
Created December 9, 2010 02:36
Use hard links instead of copying files during builds.
@jstangroome
jstangroome / Set-BuildDefinitionPaths.ps1
Created January 17, 2011 23:36
Update build definition paths by branch
#requires -version 2.0
[CmdletBinding()]
param (
[parameter(Mandatory=$true)]
[string]
$BuildDefinitionName,
[parameter(Mandatory=$true)]
[string]
$ProjectName)
@jstangroome
jstangroome / Set-TfsNotificationJobDelay.ps1
Created January 18, 2011 01:57
Configure TFS notification delays
#requires -version 2.0
param (
[parameter(Mandatory=$true)]
[string]
$Url,
[ValidateRange(0, 86400)]
[int]
$DelaySeconds = 120
)
@jstangroome
jstangroome / gist:785710
Created January 19, 2011 04:57
Download a file from TFS 2010 source control via PowerShell
$CollectionUrl = 'http://localhost:8080/tfs/defaultcollection'
Add-Type -AssemblyName 'Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Add-Type -AssemblyName 'Microsoft.TeamFoundation.VersionControl.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
$Collection = New-Object -TypeName Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $CollectionUrl
$VersionControl = $Collection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$DestinationFile = [IO.Path]::GetTempFileName()
$VersionControl.DownloadFile('$/Test/BuildProcessTemplates/DefaultTemplate.xaml', $DestinationFile)
@jstangroome
jstangroome / Set-TfsLastWriteTime.ps1
Created January 21, 2011 00:42
Change TFS workspace file stamps to match server check-in times
#requires -version 2.0
[CmdletBinding()]
param (
[string]
$Path = ((Get-Location).ProviderPath)
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
@jstangroome
jstangroome / Send-RemotingFile.ps1
Created January 22, 2011 13:04
Transfers a single file to another machine via the PowerShell Remoting protocol
#requires -version 2.0
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]
$ComputerName,
[Parameter(Mandatory=$true)]
[string]
@jstangroome
jstangroome / gist:819902
Created February 10, 2011 03:45
Detect 32-bit PowerShell inside a script and switch to 64-bit PowerShell via PS Remoting
if (Test-Path Env:PROCESSOR_ARCHITEW6432) {
Write-Host "Switching to 64-bit PowerShell"
Invoke-Command -ComputerName localhost -ScriptBlock {
param ($Path, $Parameters)
& $Path @Parameters
} -ArgumentList $MyInvocation.MyCommand.Path, $PSBoundParameters
return
}
@jstangroome
jstangroome / gist:823580
Created February 12, 2011 07:37
A simple solution for executing 64-bit PowerShell commands from 32-bit PowerShell without using PS Remoting or requiring administrative privileges
function Invoke-OSArchitectureCommand (
[Parameter(Mandatory=$true)]
[ScriptBlock]
$ScriptBlock,
$ArgumentList
) {
if ($PSHOME -match '\\syswow64\\') {
$PowerShellx64 = $PSHOME -replace '\\syswow64\\','\sysnative\' | Join-Path -ChildPath powershell.exe