Skip to content

Instantly share code, notes, and snippets.

View michaelkc's full-sized avatar

Michael Christensen michaelkc

View GitHub Profile
@michaelkc
michaelkc / CallDlbrCommonLoginSecuredServiceWithToken.ps1
Created April 23, 2018 14:52
Call DLBR Common Login secured service from PowerShell
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
# config.json example contents:
# {
# "Audience": "<some service audience>",
# "Serviceurl": "<some service url>",
# "Idp": "idp.dlbr.dk",
# "Serviceaccountusername": "<some service account username>",
# "Serviceaccountpassword": "<some service account password>"
@michaelkc
michaelkc / git-pull-all.ps1
Created March 27, 2018 20:11
Powershell variant of the git-pull-all command, to pull all git repos in subfolders of current folder
$git = "git.exe" # or change to absolute path if not in PATH
$gitRepos = Get-ChildItem -Recurse -Directory | Where-Object { Get-ChildItem $_.FullName -Directory -Hidden -Filter ".git" }
foreach ($gitRepo in $gitRepos)
{
Write-Host "Pulling $($gitRepo.Fullname)"
pushd
cd $gitRepo.Fullname
&$git pull
popd
}
@michaelkc
michaelkc / adfs2016cmdlethangrepro.ps1
Last active March 9, 2018 08:33
ADFS v2016 cmdlet hang repro
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$VerbosePreference = "Continue"
# https://social.technet.microsoft.com/Forums/ie/en-US/8553bfcb-6170-4c25-8cb7-0f83e3bb0370/periodic-hangs-when-using-the-builtin-adfs-powershell-cmdlets-in-adfs-v2016?forum=ADFS
$iterations = 50
$sw = [system.diagnostics.stopwatch]::startNew()
$rpNames = 1..50|ForEach-Object { "HangReproRP$_" }
Write-Verbose "Ensuring repro RPs are created..."
import sublime, sublime_plugin, random, string, os
class saveunnamedbuffersCommand(sublime_plugin.TextCommand):
def run(self, edit):
print("Init")
for window in sublime.windows() :
for view in window.views() :
dirty = view.is_dirty()
filename = str(view.file_name())
print(str(dirty) + " " + filename)
using System;
using System.Configuration;
using System.IdentityModel.Tokens;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
using Dlbr.CommonLogin.Owin;
using Microsoft.IdentityModel.Extensions;
using Microsoft.IdentityModel.Protocols;
using Microsoft.Owin.Logging;
<?xml version="1.0" encoding="utf-8"?>
<PortableRelyingParty xmlns="http://schemas.datacontract.org/2004/07/Dlbr.CommonLogin.AdfsSnapIn" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AutoUpdateEnabled>false</AutoUpdateEnabled>
<ClaimsAccepted />
<ConflictWithPublishedPolicy>false</ConflictWithPublishedPolicy>
<DelegationAuthorizationRules />
<Enabled>true</Enabled>
<EncryptClaims>true</EncryptClaims>
<EncryptedNameIdRequired>false</EncryptedNameIdRequired>
<EncryptionCertificateRevocationCheck>CheckChainExcludeRoot</EncryptionCertificateRevocationCheck>
@michaelkc
michaelkc / ensureWHS.ps1
Last active August 29, 2015 14:14
Creating web hosting plan and ensuring websites and staging slots all use it
Import-Module Azure
Set-StrictMode -version 4
$location = "North Europe"
$resourceGroupName = 'Default-Web-' + $location.Replace(' ', '');
$webHostingPlanName = "StandardSmall";
$websiteResourceType = "Microsoft.Web/sites";
$stagingSlotResourceType = "Microsoft.Web/sites/slots";
function New-AzureWebHostingPlan($hostingPlanName)
{
@michaelkc
michaelkc / EnableRemoteDesktop.ps1
Last active June 29, 2016 13:38
EnableRemoteDesktop.ps1
# wget tinyurl.com/enablerdp -outfile .\rdp.ps1
# .\rdp.ps1
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1
@michaelkc
michaelkc / BoxStarter2012R2ADFS
Last active August 29, 2015 14:11
BoxStarter2012R2ADFS
# Invoke using following syntax:
# http://boxstarter.org/package/url?[input url to this gists]
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy Unrestricted
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$csprojInFile,
[Parameter(Mandatory=$True,Position=2)]
[string]$csprojOutFile
)
$csproj = [xml](get-content $csprojInFile)
$xmlns = $csproj.Project.xmlns