Skip to content

Instantly share code, notes, and snippets.

View Tiberriver256's full-sized avatar
📚
Still learning

Micah Rairdon Tiberriver256

📚
Still learning
View GitHub Profile
@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.
@Tiberriver256
Tiberriver256 / Set-Transparency.ps1
Last active March 6, 2024 03:49
Make any window transparent using PowerShell. Modified from https://gist.github.com/grenade/ed8dd77ae8eeb5b4a3c1cfd66e9c8ae7
$user32 = Add-Type -Name 'user32' -Namespace 'Win32' -PassThru -MemberDefinition @'
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, uint crKey, int bAlpha, uint dwFlags);
@Tiberriver256
Tiberriver256 / FindPortProcessName
Created March 12, 2019 14:32
Find what process is using a port on Windows
$Port = "8080"
netstat -a -n -o | where { $_ -match $Port } | foreach {
$Process = Get-Process -PID (($_ -replace "\s+"," ") -split " ")[-1]
"Process: $($Process.ProcessName) ($($Process.Id)) is using $Port"
}
@Tiberriver256
Tiberriver256 / index.html
Last active January 30, 2024 10:58
GistPad - Template (Basic - HTML/JS/CSS)
<div class="playingCards fourColours faceImages">
<div class="card rank-7 spades">
<span class="rank"></span>
<span class="suit"></span>
</div>
</div>
<div class="playingCards faceImages">
<div class="card rank-7 diams">
<span class="rank"></span>
@Tiberriver256
Tiberriver256 / Get-DadJokeIpsum.ps1
Created July 23, 2021 13:55
Get me some dad jokes
<#
.SYNOPSIS
Get some filler text that is dad jokes
.PARAMETER minLength
The minimum length of text you need
PS> Get-DadJokeIpsum -minLength 500
Where did Captain Hook get his hook? From a second hand store. Why was the broom late for the meeting? He overswept. Dad, can you put my shoes on? I don't think they'll fit me. For Valentine's day, I decided to get my wife some beads for an abacus. It's the little things that count. Why is the ocean always blue? Because the shore never waves back. How does a dyslexic poet write? Inverse. Whiteboards ... are remarkable. Want to hear a joke about construction? Nah, I'm still working on it. Why do scuba divers fall backwards into the water? Because if they fell forwards theyâd still be in the boat. Some people say that comedians who tell one too many light bulb jokes soon burn out, but they don't know watt they are talking about. They're not that bright. Don't trust atoms. They make up everything. I am terrified of elevators. Iâm going to start taking steps to
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService -credential $UserCredential
$ReportPath = "C:\filename"+ (Get-Date -UFormat %D).Replace("/",".") +".csv"
$Report = @()
@Tiberriver256
Tiberriver256 / lilPowerShellNotepadSearcher.ps1
Last active January 14, 2024 07:04
This is a tiny little PowerShell script that will find any files you have open in Notepad and present them in out-gridview with lines to help with searching. Large files it will prompt you for a pre-search term or a regex to make it usable in out-gridview. Super handy for when you get logs in Outlook and don't want to save them to somewhere spec…
$FilePaths = @()
$FilePaths = (Get-WmiObject win32_process -filter "name like 'notepad.exe'") |
foreach { ($_.commandline -split " ",2)[1] }
if($FilePaths.count -gt 1) {
$FilePath = $FilePaths | Out-GridView -PassThru -Title "Select the open file you would like to search"
} else {
$FilePath = $FilePaths
}
@Tiberriver256
Tiberriver256 / FindPortProcessName.ps1
Created March 12, 2019 14:33
Gets the process name and PID for a given port
$Port = "8080"
netstat -a -n -o | where { $_ -match $Port } | foreach {
$Process = Get-Process -PID (($_ -replace "\s+"," ") -split " ")[-1]
"Process: $($Process.ProcessName) ($($Process.Id)) is using $Port"
}
<#
.SYNOPSIS
Copy files using your clipboard and PowerShell
.DESCRIPTION
The file specified at $Path is converted to a base64 string, wrapped with a tiny script that converts the base64 string
back to binary and saves it at the path specified in the $Destination parameter
#>
function Copy-PasteItem {
[CmdletBinding()]
Function Show-Diff {
param([String[]]$OldString,[String[]]$NewString)
$WebPage = @"
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />