Skip to content

Instantly share code, notes, and snippets.

View abombss's full-sized avatar

Adam Tybor abombss

  • Accenture
  • Chicago, IL
View GitHub Profile
@abombss
abombss / MyHttpWebRequest.cs
Created May 16, 2013 16:34
Inherit from HttpWebRequest... pure evil will ensue.
public class MyHttpWebRequest : HttpWebRequest
{
private static readonly IFormatterConverter Converter = new FormatterConverter();
private static readonly StreamingContext Context = new StreamingContext(StreamingContextStates.Clone);
public MyHttpWebRequest(string url)
: this(new Uri(url))
{
}
@abombss
abombss / sample.ps1
Created April 18, 2013 07:49
TFS and Powershell
# Load some types initially so the cmdlets work
Add-TFSApiAssembly
# Create a TFS TeamProjectCollection and extend it with some common service properties for easy access
$tfs = Get-Tfs -Uri https://tfs.somedomain.com/tfs/ProjectCollection -Services BS, VCS, TM -Verbose
# You can write cmdlets or you can use the built in API and add your own extensions
$buildDefinitions = Get-TfsBuildDefinition -Tfs $tfs -TeamProject MyProject
# $buildDefinitions = $tfs.BS.QueryBuildDefinitions('MyProject')
@abombss
abombss / Add-GitIgnore.ps1
Last active December 15, 2015 11:49
Add-GitIgnore
function Add-GitIgnoreForVS ([switch]$DisableNugetRestore,[switch]$PassThru) {
$cmdArgs = @{
Name="VisualStudio"
PassThru=$PassThru
Uncomment=( & {if($DisableNugetRestore) { @() } else { @("packages/") } })
}
Add-GitIgnore @cmdArgs
}
function Add-GitIgnore ([string]$Name, [switch]$PassThru, [string]$UserRepo="github/gitignore", [string]$Branch="master", [string[]]$Uncomment) {
@abombss
abombss / DumpItems.xml
Created March 20, 2013 23:54
Dump ItemGroups and metadata from msbuild
<!--?xml version="1.0" encoding="utf-8"?-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask
TaskName="LogItems"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<Items Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<Metadata ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<Importance />
@abombss
abombss / ReflectOverAssemblyAttributes.cs
Last active August 22, 2016 15:21
Collect all assembly attributes using a reflection only load of an assembly
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Policy;
namespace MsBuild.AssemblyFu
{
internal interface IAssemblyAttributeGetter
@abombss
abombss / PsLocalDb.psm1
Created March 6, 2013 21:22
Powershell LocalDb Wrapper
function Start-LocalDb {
[CmdletBinding()]
param(
[Parameter(Mandatory,ValueFromPipeLine,Position=1)]
[psobject[]]$Instance,
[string]$ToolPath = (Find-LocalDbExe)
)
begin {
}
@abombss
abombss / Install-AppFabricCache.ps1
Last active December 10, 2015 20:38
Automatically Install AppFabric Cache Cluster and Nodes
function Uninstall-AppFabricCacheNode {
#TODO: Should try and remove the configuration stuff
gwmi win32_product -filter "Name LIKE 'AppFabric%'" |% {
$key="IdentifyingNumber=`"$($_.IdentifyingNumber)`",Name=`"$($_.Name)`",version=`"$($_.Version)`"";
([wmi]"Win32_Product.$key").uninstall()
}
}
function Reset-AppFabricCacheDatabase {
param(
@abombss
abombss / Get-ArchiveItems.ps1
Created November 14, 2012 03:54
Powershell List Zip Archive File Contents
function Get-ArchiveItems {
param([Parameter(Mandatory)][string]$Archive)
function recurse-items {
param([object]$items)
foreach($item in $items) {
$item
$folder = $item.GetFolder
if ($folder) {
recurse-items $folder.Items()
@abombss
abombss / Util.ps1
Created August 30, 2012 21:24
Handy Powershell Cmdlets
Function Where-ObjectMatches() {
[CmdletBinding(DefaultParameterSetName="MatchLike")]
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("Value", "Input", "Object", "io")]
[psobject[]]$InputObject,
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,Position=1)]
[Alias("Selector")]
[psobject]$Property,
@abombss
abombss / PSAddMember.psm1
Created August 8, 2012 19:02
PSAddMember -- Extend all objects with an easier to use PSAddMember function
Function PSAddMember() {
$this = $args[0]
switch($args.Count) {
2 {
($args[1] -as [HashTable]) | %{ $_.GetEnumerator() } | %{ Add-Member -InputObject $this -Name $_.Name -value $_.Value -MemberType Noteproperty -Force -PassThru }
break;
}
3 {