Skip to content

Instantly share code, notes, and snippets.

@jborean93
jborean93 / Trace-TlsHandshake.ps1
Last active December 7, 2023 14:49
Debug TLS Handshakes using .NET
# Copyright: (c) 2022, Jordan Borean (@jborean93) <[email protected]>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Trace-TlsHandshake {
<#
.SYNOPSIS
TLS Handshake Diagnostics.
.DESCRIPTION
Performs a TLS handshake and returns diagnostic information about that
@lukejjh
lukejjh / ToggleDarkMode.ps1
Created August 22, 2021 00:08
PowerShell script that toggles dark mode in Windows 10/11, for both apps and system.
$k = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
$v = (Get-ItemProperty -Path $k).SystemUsesLightTheme -bxor 1
Set-ItemProperty -Path $k -Name "SystemUsesLightTheme" -Value $v
Set-ItemProperty -Path $k -Name "AppsUseLightTheme" -Value $v
@brianvanderlugt
brianvanderlugt / PreRequisites.ps1
Last active April 12, 2025 20:53
PowerShell script to output graph dependency to help resolve nuget dependencies.
#Requires -RunAsAdministrator
# Pre-requisites
Install-Module PowerShellGet -Force # to install additional packages
Import-Module PowerShellGet -MinimumVersion 2.2.0
# Doesn't work because PowerShellGet doesn't support SemVer 2.0 yet. https://github.com/PowerShell/PowerShellGet/issues/222
Install-Package NuGet.Core,NuGet.ProjectModel
# Instead run. Recommmend copy as installs additional libraries already cover by NETStandard 2.0
@KirillOsenkov
KirillOsenkov / Directory.Build.props
Created April 12, 2019 16:56
SDK-style Directory.Build.props for common output directory
<Project>
<PropertyGroup>
<SrcRoot>$(MSBuildThisFileDirectory)</SrcRoot>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(SrcRoot)\</SolutionDir>
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
@MaxMelcher
MaxMelcher / devops_win.ps1
Last active February 20, 2024 07:02
Powershell to install the latest Azure DevOps Agent
param (
[string]$URL,
[string]$PAT,
[string]$POOL,
[string]$AGENT
)
Write-Host "start"
if (test-path "c:\agent")
@RomelSan
RomelSan / Powershell-Certificates-BRIEF.ps1
Last active May 2, 2024 02:43
Powershell Self Signed Certificate
#-------------------------------------------------------------------------------------
# Create Self signed root certificate
# -dnsname -DnsName domain.example.com,anothersubdomain.example.com
# -Subject "CN=Patti Fuller,OU=UserAccounts,DC=corp,DC=contoso,DC=com"
$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature `
-Subject "CN=P2SRootCert" `
-KeyExportPolicy Exportable `
-HashAlgorithm sha256 -KeyLength 4096 `
-CertStoreLocation "Cert:\CurrentUser\My" `
-KeyUsageProperty Sign `
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
@jbe2277
jbe2277 / AssemblyAnalyzer.cs
Created July 2, 2017 17:52
AssemblyAnalyzer via System.Reflection.Metadata
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
@atao
atao / RunAsAdmin.ps1
Last active October 1, 2023 19:34
🕵️ Self privileges escalation with PowerShell.
#Requires -RunAsAdministrator
#OneLine
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
#Or
$Loc = Get-Location
"Security.Principal.Windows" | % { IEX "( [ $_`Principal ] [$_`Identity ]::GetCurrent() ).IsInRole( 'Administrator' )" } | ? {
$True | % { $Arguments = @('-NoProfile','-ExecutionPolicy Bypass','-NoExit','-File',"`"$($MyInvocation.MyCommand.Path)`"","\`"$Loc\`"");
Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $Arguments; } }
@gavincampbell
gavincampbell / Install-Latest-Pester.ps1
Created February 28, 2017 11:45
Powershell script to download and extract the latest version of [Pester](https://github.com/pester/Pester)
$latestRelease = Invoke-WebRequest https://github.com/pester/Pester/releases/latest -Headers @{"Accept"="application/json"}
$json = $latestRelease.Content | ConvertFrom-Json
$latestVersion = $json.tag_name
$url = "https://github.com/pester/Pester/archive/$latestVersion.zip"
$download_path = "$env:USERPROFILE\Downloads\pester-master.zip"
Invoke-WebRequest -Uri $url -OutFile $download_path
Get-Item $download_path | Unblock-File