Skip to content

Instantly share code, notes, and snippets.

View zachbonham's full-sized avatar

Zach Bonham zachbonham

View GitHub Profile
@zachbonham
zachbonham / bootstrap_server.ps1
Created May 8, 2012 14:58
Required Bootstrapping of WinRM before its of any value for PowerShell Remoting
param($computername=$(throw "-computername is required"), $username=$(throw "-username is required"), $password=$(throw "-password is required"))
<#
.SYNOPSIS
Bootstraps a server for use with WinRM.
Requires running under a username which is an adminstrator on remote machine.
Requires PSEXEC from sysinternals
@zachbonham
zachbonham / bootstrap_client.ps1
Created May 8, 2012 14:59
Required foo to bootstrap a client for PowerShell Remoting
set-executionpolicy Unrestricted
winrm quickconfig -quiet
enable-wsmancredssp -role client -delegatecomputer *
@zachbonham
zachbonham / crypto.cs
Created September 10, 2012 17:57
RSA public key encryption in C#
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
namespace Crtypto
{
class Program
{
static void Main(string[] args)
@zachbonham
zachbonham / unmerged.ps1
Created September 26, 2012 19:32
Reporting on unmerged changesets in TFS
<#
Report on unmerged changesets for release planning.
#>
function get_unmerged_changesets($source, $target)
{
write-host "getting unmerged changesets for $source and $target"
$changesets = @()
@zachbonham
zachbonham / box.ps1
Last active December 11, 2015 07:48
Internal PowerShell DSL for VM template descriptions. A Hyper-V, or Azure, provider would actually instantiate from metadata (see bottom).
set-psdebug -strict
# bleh
#
$global:boxes = @{}
<#
Here we are defining an internal PowerShell DSL for creating 'boxes'.
@zachbonham
zachbonham / retry.ps1
Last active December 12, 2015 12:49
Retriable implementation in PowerShell completely ripped off from an implementation in Ruby.
# complete rip off of http://blog.mirthlab.com/2012/05/25/cleanly-retrying-blocks-of-code-after-an-exception-in-ruby/
#
# usage
# retriable -tries 5 -action { do-work-that-could-throw-exception }
#
function retriable($tries=3, $interval=1, [scriptblock]$action)
{
@zachbonham
zachbonham / driver.ps1
Created February 19, 2013 00:57
foreman prototype in powershell. Mainly the CTRL+C break for powershell.
$arg1 = "hello1"
$arg2 = "hello2"
$p = $(start-process -filepath .\bin\debug\hello.exe -argumentlist $arg1 -nonewwindow -passthru; start-process -filepath .\bin\debug\hello.exe -argumentlist $arg2 -nonewwindow -passthru);
#$p | wait-process
[console]::TreatControlCAsInput = $true
while($true)
@zachbonham
zachbonham / hello.ps1
Last active December 14, 2015 11:58
Testing download and execute powershell from github gist
write-host "machine $($env:computername)"
write-host "hello, $($env:computername) "
@zachbonham
zachbonham / SpecRunner.html
Last active December 19, 2015 01:28
Example WInJS class declaration which works from within project, but not from within spec. Spec throws an exception "TypeError: Object doesn't support property or method 'print'" when I try to call print(). I notice this is also true when I try to call a method of ViewModel.LogIn.
<!-- snippet showing how referencing print.js -->
<script type="text/javascript" src="../WorkItemGlass.Metro.UI/js/viewModels.js"></script>
<script type="text/javascript" src="../WorkItemGlass.Metro.UI/js/print.js"></script>
<script type="text/javascript" src="../WorkItemGlass.Metro.UI\pages\login\loginViewModel.js"></script>
@zachbonham
zachbonham / SuperAppWeb.ps1
Last active December 22, 2015 23:08
Website resource doesn't do anything, error, etc. No documentation in the PDF overview download. However, un-commenting 'Foo' resource will result in an error.
param($machineName = $(hostname))
Configuration SuperAppWeb
{
Node ($machineName)
{
<#
nothing happens when trying to use this resource?
#>
Website DefaultSite