Skip to content

Instantly share code, notes, and snippets.

@david-mclean
david-mclean / CreateAppPool.ps1
Last active August 29, 2015 14:23
Powershell scripts used to easy deploying to IIS from a package created by build server. These scripts are already 18 months old, we actually call product specific deployment script from ReleaseManagment that uses these scripts.
param(
[string] $appPoolName = $(throw "::REQUIRED PARAMETER:: -appPoolName"),
[string] $username = $(throw "::REQUIRED PARAMETER:: -username"),
[string] $password = $(throw "::REQUIRED PARAMETER:: -password"),
[string] $appPoolDotNetVersion = "v4.0",
[switch] $classicMode
)
Import-Module WebAdministration
cd IIS:\AppPools\
@david-mclean
david-mclean / BasicFizzBuzz.cs
Last active August 29, 2015 14:23
Playing with FizzBuzz
public class FizzBuzz
{
public IEnumerable<string> Execute(int max)
{
for(int i = 1; i <= max; i++)
{
if(i%15==0)
yield return "fizzbuzz";
else if(i%5==0)
yield return "buzz";
@david-mclean
david-mclean / ElevatedUserPerms.ps1
Last active July 19, 2017 12:03
Elevate permissions of powershell script
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
if ($myWindowsPrincipal.IsInRole($adminRole))
{
@david-mclean
david-mclean / gist:5228693
Last active December 15, 2015 08:09
Use yield to return a few items from an iterator.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
namespace YieldExample
{
class Program
{
@david-mclean
david-mclean / gist:5228317
Created March 23, 2013 16:29
An example of using yield.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace YieldExample
{
class Program
{
static void Main(string[] args)