Skip to content

Instantly share code, notes, and snippets.

Avatar

HumanEquivalentUnit

View GitHub Profile
@HumanEquivalentUnit
HumanEquivalentUnit / Invoke-WithImpersonation.ps1
Created Aug 12, 2020 — forked from jborean93/Invoke-WithImpersonation.ps1
Invoke a scriptblock in powershell with impersonation
View Invoke-WithImpersonation.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Add-Type -Namespace PInvoke -Name NativeMethods -MemberDefinition @'
[DllImport("Kernel32.dll")]
public static extern bool CloseHandle(
IntPtr hObject);
[DllImport("Advapi32.dll", SetLastError = true)]
public static extern bool ImpersonateLoggedOnUser(
@HumanEquivalentUnit
HumanEquivalentUnit / phaseI.dyalog
Created Aug 1, 2020
Dyalog APL Competition 2020 - Phase I solutions
View phaseI.dyalog
((0>)((),())) 1. Let's Split
((128>191<)) 2. Characters
{26⎕A} 3. Columns
{(0=400|)(0=4 100.|)} 4. Take a Leap
{⎕IO0 (>/)(/)+1+(/-/)} 5. Stepping
{[=]} 6. Move To Front
{=2bits2bits2¯1} 7. Bits
{(/(1 ¯1)(×2-/))10¯1} 8. Zigzag
{peak(/), notDesc() (notDesc peak) (notDesc peak)} 9. Rise and fall
10. Stacking It Up - not done
View phone-numpad-words.ps1
$keys = @{
'1'='' ; '2'='[abc]'; '3'='[def]' ;
'4'='[ghi]' ; '5'='[jkl]'; '6'='[mno]' ;
'7'='[pqrs]'; '8'='[tuv]'; '9'='[wxyz]';
}
$nums = '76937'
$pattern = foreach ($char in $nums.GetEnumerator())
@HumanEquivalentUnit
HumanEquivalentUnit / notes.dyalog
Last active Dec 21, 2019
PowerShell Cmdlet in Dyalog APL proof of concept
View notes.dyalog
This is in a workspace, default namespace
created by )Ed ○InvokeAplExpression
Then exported as a Microsoft .Net Assembly
With the Isolation Mode dropdown set to
'Each assembly attempts to use local bridge and interpreter libraries'
pre-req: make a project folder e.g. "D:\m\" and copy file
System.Management.Automation.dll from the .Net GAC into it.
PS> Copy-Item -Path ([psobject].Assembly.Location) -Destination 'd:\m\' -Verbose
View delete-remote-deployment-files.ps1
# Parameters
param(
[string] $ComputerList = $(Join-Path -Path $PSScriptRoot -ChildPath "computers.txt"), # Path to the list of computers
[string] $ReportPath = $(Join-Path -Path $PSScriptRoot -ChildPath "report.csv"), # Path to the report to output
[switch] $DeleteFolder = $false # Whether to delete MININT or not
)
Get-Content $ComputerList | ForEach-Object {
$result = @{
@HumanEquivalentUnit
HumanEquivalentUnit / MenuTest.ps1
Created Nov 16, 2018
PowerShell + Windows Forms dynamic dropdown menu from filesystem example
View MenuTest.ps1
# These are the starting folders
$documentRoots = 'C:\Users\', 'C:\Program Files\'
# Load Windows forms assemblies
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][Reflection.Assembly]::LoadWithPartialName("System.Drawing")
View Test-PasswordComplexity-v3.ps1
<#
.Synopsis
Tests a string against Active Directory default password complexity requirements
.DESCRIPTION
Checks password length, and whether it meets 3 out of 4 of the following:
- Lowercase character a-z
- Uppercase character A-Z
- Digit 0-9
- Special character !,#,-, etc.
View gist:9756f97bc67d2a0807993c05e426a436
# Map URLs to Internet Explorer Security Zones via PowerShell
$csSource = @'
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
public class IEZones
{
@HumanEquivalentUnit
HumanEquivalentUnit / gist:c00db7ceb2fdba17931145e27c71b0ee
Created Aug 3, 2018
Bodge-add binary literal number support to PowerShell
View gist:c00db7ceb2fdba17931145e27c71b0ee
$ExecutionContext.InvokeCommand.CommandNotFoundAction = {
param($Name,[System.Management.Automation.CommandLookupEventArgs]$CommandLookupArgs)
$CommandLookupArgs.CommandScriptBlock = {
if ($CommandLookupArgs.CommandName -match '(?<binary>1[10]*)b$')
{
[convert]::ToInt32($matches['binary'], 2)
}
@HumanEquivalentUnit
HumanEquivalentUnit / Get-SslCertFromThawteApprovalEmail.ps1
Created Feb 7, 2018
PowerShell script to export SSL Certificate delivery emails to .crt files
View Get-SslCertFromThawteApprovalEmail.ps1
# Automates Outlook
# - searches the Inbox for Thawte
# 'your SSL certificate has been approved' messages
# - extracts the certificate to disk with a useful filename
# - deletes the emails
$VerbosePreference = 'continue'
$OutputFolder = '\\server\share\SSL Cert Deliveries\'
You can’t perform that action at this time.