Skip to content

Instantly share code, notes, and snippets.

# Original form stackoverflow, can find the uri, answer by mklement0
$start = Get-Date
$queue = [System.Collections.Concurrent.ConcurrentQueue[string]]::new()
$job = Start-ThreadJob {
$queue = $using:queue
$item = $null
while ($true) {
while ($queue.TryDequeue([ref] $item)) {
if ("`0" -eq $item) { 'Quitting...'; return }
# PowerShell version of the original I found https://pastebin.com/cX6nupy4
foreach ($Package in (Get-ChildItem C:\WINDOWS\servicing\Packages\*Hyper-V*.mum).FullName) {
dism /online /norestart /add-package:$Package
}
dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
@affieuk
affieuk / ClientIP.cs
Created January 5, 2018 14:31 — forked from winzig/ClientIP.cs
If you're using a load balancer that obscures the remote client's true IP address, you can run this IHttpModule to take the first IP address from the X-Forwarded-For header, and overwrite the REMOTE_ADDR and REMOTE_HOST server variables. (We tried to use the URL Rewrite module that everyone normally recommends to do this, but it's buggy.)
using System;
using System.Web;
using System.Text.RegularExpressions;
namespace HttpModules
{
/// <summary>
/// This module handles complications from our load balancer configuration not properly passing the client's true IP
/// address to our code via the REMOTE_ADDR and REMOTE_HOST variables. We tried to use URL Rewrite to compensate for
/// this, but it does not run when default documents are being accessed (a longstanding bug).
Function New-PSWebServer {
<#
.Synopsis
Creates a web server that will invoke PowerShell code based on routes being asked for by the client.
.Description
New-PSWebServer creates a web server. The web server is composed of a schema that defines the client's requests to routes where PowerShell code is executed.
Under the covers, New-PSWebServer uses the HTTPListener .NET class to execute powershell code as requested, retrieves the results and sends data back through the httplistener web server framework.