Skip to content

Instantly share code, notes, and snippets.

@JustinGrote
JustinGrote / Receive-Task.ps1
Last active September 21, 2022 21:05
"Await" one or more tasks in PowerShell in a cancellable manner (e.g. ctrl-c still works)
using namespace System.Threading.Tasks
using namespace System.Collections.Generic
filter Receive-Task {
#Wait on one or more tasks in a cancellable manner
[CmdletBinding()]
param(
[parameter(Mandatory, ValueFromPipeline)][Task]$Task,
#How long to wait before checking for a cancellation in milliseconds
[int]$WaitInterval = 500
)
[CmdletBinding()]
PARAM(
[Parameter(Mandatory=$true)][String] $CredentialPath,
[Parameter(Mandatory=$true)][String] $Resource
)
try
{
$Token = $null
@rithvikvibhu
rithvikvibhu / README.md
Last active April 12, 2024 15:32
GHLocalApi Update

GHLocalApi Update

The Gist

Until recently, the Google Home app used to communicate with the device over port 8008 (HTTP) and did not require any authentication. Everything in the unofficial documentation worked as expected.

A few days (weeks) ago, Google pushed a new update to all GH devices and all endpoints (except /setup/eureka_info) started returning 403 (forbidden) errors. The app had switched over to port 8443 and HTTPS.

@jstnlvns
jstnlvns / git: gitignore.md
Created November 16, 2018 19:42
a gitignore cheatsheet

Git sees every file in your working copy as one of three things:

  1. tracked - a file which has been previously staged or committed;
  2. untracked - a file which has not been staged or committed; or
  3. ignored - a file which Git has been explicitly told to ignore.

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:

  • dependency caches, such as the contents of /node_modules or /packages
  • compiled code, such as .o, .pyc, and .class files
@Tiberriver256
Tiberriver256 / APlayingAroundWithKestrel.ps1
Last active March 2, 2023 00:24
Trying to get Kestrel working in PowerShell...
using namespace Microsoft.AspNetCore.Builder;
using namespace Microsoft.AspNetCore.Http;
using namespace System;
using namespace Microsoft.AspNetCore.Hosting;
# If you don't have Visual Studio Installed this should work fine
# Install-Package Microsoft.AspNetCore -Source nuget.org -Destination .\.nuget\packages
# Install-Package Microsoft.AspNetCore.Server.Kestrel -Source nuget.org -Destination .\.nuget\packages
$LibFolder = ""
@SP3269
SP3269 / VerifyJWTSignature.ps1
Created January 5, 2018 05:53
JWT verification in Powershell - prototype
# JWT signature verification
# $jwt should contain the JWT as a string
$parts = $jwt.Split('.')
$SHA256 = New-Object Security.Cryptography.SHA256Managed
$computed = $SHA256.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($parts[0]+"."+$parts[1]))
# Method A - just using X509Certificate2. TODO: initialise from file, no private key
# Reference: https://blogs.msdn.microsoft.com/alejacma/2008/06/25/how-to-sign-and-verify-the-signature-with-net-and-a-certificate-c/
@msoler8785
msoler8785 / Create-PtrRecords.ps1
Last active July 4, 2024 00:57
Quick PowerShell script to automate PTR Record creation for existing forward lookup zones.
# Creates PTR Records for all A Records in the specified -ZoneName.
# Uses a Class A Subnet for the reverse zone.
$computerName = 'dns-server01';
# Get all the DNS A Records.
$records = Get-DnsServerResourceRecord -ZoneName 'zone.example.com' -RRType A -ComputerName $computerName;
foreach ($record in $records)
{
# The reverse lookup domain name. This is the PTR Response.
$ptrDomain = $record.HostName + '.zone.example.com';
@Tiberriver256
Tiberriver256 / PSWebServer.psm1
Last active March 6, 2024 03:49
Sample of making a simple webserver in PowerShell. If you have more complex needs checkout Pode (https://github.com/Badgerati/Pode) as a fully fledged PowerShell web server.
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.
# Modified Example From : https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/28/beginning-use-of-powershell-runspaces-part-3/
# Added import of all current session functions into the sessionstate for the runspacepool
# --------------------------------------------------
#region - Setup custom functions
# --------------------------------------------------
# Create custom function to import into runspace session state
Function ConvertTo-Hex {
@alirobe
alirobe / reclaimWindows10.ps1
Last active July 3, 2024 09:36
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###