Skip to content

Instantly share code, notes, and snippets.

View 1-Installation.markdown

Installation (Quick Start)

To install the prompt, run the following PowerShell command:

iex (New-Object Net.Webclient).DownloadString('')

That's it.

nzbart / Get-WebRequestSummary.psm1
Last active November 1, 2018 20:23
Get-WebRequestSummary returns a list of requests currently executing against IIS 8 (Windows 8 or Windows Server 2012).
View Get-WebRequestSummary.psm1
Add-Type -TypeDefinition @"
public enum PipelineStateFlags
Unknown = 0,
BeginRequest = 1,
AuthenticateRequest = 2,
AuthorizeRequest = 4,
ResolveRequestCache = 8,
MapRequestHandler = 16,
nzbart / CreateFolderWithPermissions.ps1
Created June 14, 2013 22:43
Resets all permissions on a folder to a specified set. I use this on IIS web roots in deployment scripts. The function: * Creates the folder if it does not exist * Sets permissions on the folder and configures those permissions to propagate to child folders and files * Resets all child objects so that they match the parent folder
View CreateFolderWithPermissions.ps1
function CreateFolderWithPermissions($folder, $aclRules)
if(-not (test-path $folder)) {
Write-Host "Creating $folder..."
md $folder | out-null
Write-Host "Setting permissions on $folder..."
$domain = [environment]::userdomainname
$acl = new-object System.Security.AccessControl.DirectorySecurity
nzbart / Program.cs
Last active December 19, 2015 08:38
A quick app to test the latency overhead of asynchronous calls in .NET.
View Program.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace ConsoleApplication6
class Program
static void Main()
nzbart / gist:8014740
Last active December 31, 2015 16:39
Allow multiple web applications under IIS to use the same SQL server session state database without modifying the database stored procedures.
View gist:8014740
* This code is a workaround for the fact that session state in ASP.NET SqlServer mode is isolated by application. The AppDomain's appId is used to
* segregate applications, and there is no official way exposed to modify this behaviour.
* Some workarounds tackle the problem by modifying the ASP.NET state database. This workaround approaches the problem from the application code
* and will be appropriate for those who do not want to alter the database. We are using it during a migration process from old to new technology stacks,
* where we want the transition between the two sites to be seamless.
* As always, when relying on implementation details, the reflection based approach used here may break in future / past versions of the .NET framework.
* Test thoroughly.
nzbart / FindBinaryFiles.cs
Last active June 25, 2016 00:32
A simple and naive C# program that will help identify binary file types in a directory.
View FindBinaryFiles.cs
* Recommended usage is to pipe in a list of paths :
* Git:
* git ls-files | FindBinaryFiles.exe
* PowerShell:
* ls -r | ? PSIsContainer | select -expand FullName | FindBinaryFiles.exe
* */
using System;
using System.Collections.Generic;
nzbart / CredWriteAndReadWithProfileLoad.cpp
Last active February 26, 2021 03:27
Read / write credentials through CredRead and CredWrite, with a profile load for good measure. Fails under PowerShell remoting.
View CredWriteAndReadWithProfileLoad.cpp
#include <SDKDDKVer.h>
#include <tchar.h>
#include <Windows.h>
#include <WinCred.h>
#include <Userenv.h>
#include <atlsecurity.h>
#include <Lmcons.h>
#include <iostream>
nzbart / Find.ps1
Created March 26, 2014 02:45
Find an remove unused scss variables through basic heuristic. Not particularly fast, but it seems to work okay.
View Find.ps1
$ourContent = ls $PSScriptRoot\MyCode -r -fi *.scss | cat
$vars = $ourContent | % {
if($_ -match '^\s*\$([a-zA-Z_-]+)\s*:') {
} | select -Unique
$allContent = ls $PSScriptRoot -r -fi *.scss | cat
$vars | ? {
$search = "\`$$_[^:]*$"
nzbart / ShowSassTree.ps1
Created March 26, 2014 19:38
Show the hierarchy of sass file imports
View ShowSassTree.ps1
param([string][parameter(mandatory)]$ParentFile, [string][parameter(mandatory)]$RootFile, [int][parameter(mandatory)]$Depth, [string][parameter(mandatory)]$IncludePath, [switch]$RenderDotFormat, [switch]$DoNotRecurse)
function RenderImports([string][parameter(mandatory)]$ParentFile, [string][parameter(mandatory)]$RootFile, [int][parameter(mandatory)]$Depth, [string][parameter(mandatory)]$IncludePath, [switch]$RenderDotFormat, [switch]$DoNotRecurse)
$ErrorActionPreference = 'Stop'
function GetRelativePath([string][parameter(mandatory)]$ParentFile, [string][parameter(mandatory)]$RootFile)
pushd (Split-Path -Parent $ParentFile)
try {
nzbart / CreateModernIEVM.ps1
Created April 7, 2014 03:59
Create a Hyper-V virtual machine for a VHD downloaded from
View CreateModernIEVM.ps1
$vhd = ls *.vhd | select -ExpandProperty Name
if(!$vhd -or $vhd.GetType().FullName -ne 'System.String') {
throw "Expected to find the VHD in the current directory."
$vmName = [System.IO.Path]::GetFileNameWithoutExtension($vhd)
Write-Host "Creating VM called $vmName..."
$newVm = New-VM -Name $vmName -MemoryStartupBytes 1024MB -SwitchName External -VHDPath (Resolve-Path $vhd) -Path . -Generation 1 -BootDevice IDE
$newVm | Set-VMProcessor -Count 2