Skip to content

Instantly share code, notes, and snippets.

View AndrewPla's full-sized avatar
🌠
Shooting for the stars!

Andrew Pla AndrewPla

🌠
Shooting for the stars!
View GitHub Profile
@Jaykul
Jaykul / WeatherEverywhere.ps1
Last active April 29, 2021 19:56
Weather Everywhere
$global:WeatherJob = Start-ThreadJob {
while($true) {
(irm "wttr.in?format=3").Trim() -replace "^.*:\s*"; sleep 300
}
} -Name WeatherQuery
$null = Register-ObjectEvent -InputObject $WeatherJob.Output -EventName DataAdded -Action {
# The $Sender is the actual Output collection
# $EventArgs includes the index at which the output was added
# Update the Window Title with the weather each time it updates
@JustinGrote
JustinGrote / Get-ActiveADServers.ps1
Created January 22, 2020 18:31
Find all Enabled Servers in Active Directory that have checked in within a certain timeframe
#Requires -module ActiveDirectory
function Get-ActiveADServers {
param(
[String]$SearchBase,
[String]$Server,
[PSCredential]$Credential,
[DateTime]$After = (get-date).AddMonths(-1)
)
$GetADComputerParams = @{
Filter = {
@AndrewPla
AndrewPla / PicoCTF2019_Based.ps1
Created December 1, 2019 18:16
This script was written to solve the Based challenge from PicoCTF 2019.
<#
.Description
This script was written to solve the Based challenge from PicoCTF 2019.
This script connects to a target computer nad port and converts the output from Base2, Base8, and Base16.
It establishes a tcp connection, answers the questions and returns the flag for this challenge.
#>
[cmdletbinding()]
param(
[string]$computer = '2019shell1.picoctf.com',
$port = '44303',
@AndrewPla
AndrewPla / Get-PublicIPInfo.ps1
Last active January 12, 2020 10:51
Returns Public IP info from ip.nf Can be ran on remote computers
function Get-PublicIPInfo {
<#
.Description
Returns Public IP info from ip.nf
.Parameter IPAddress
Supply an IP address that you would like to lookup.
.Parameter ComputerName
Names of computers to run this command on.
.Parameter Credential
Credential used by Invoke-Command when performing the lookup on a remote machine.
@AndrewPla
AndrewPla / Get-MmaEvent.ps1
Last active September 6, 2019 15:31
Get-MmaEvent
function Get-MmaEvent {
<#
.Description
Returns upcoming MMA events from https://www.whenarethefights.com/
#>
$request = Invoke-WebRequest -Uri 'https://www.whenarethefights.com/'
# Only grab the events that have a countdown.
$content = $request.Links.outertext | Where-Object {$_ -like '*days*'}
@JustinGrote
JustinGrote / Send-SendGridMailMessage
Last active December 11, 2019 03:39
A drop-in replacement for Send-MailMessage. You can get a 100 email/day sendgrid API key for free at https://sendgrid.com
function Send-SendGridMailMessage {
[CmdletBinding()]
param (
[Parameter(Mandatory)][String[]]$To,
[Parameter(Mandatory)][String]$Subject,
[String]$Body,
[Parameter(Mandatory)][String]$From,
[Switch]$BodyAsHtml,
[String]$SendGridApiKey = $env:SENDGRID_API_KEY
)
@AndrewPla
AndrewPla / Add-WindowsTerminalSchemes.ps1
Last active February 7, 2022 09:18
Updates the Windows Terminal profiles.json file with all the schemes from https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/windowsterminal
# Path to the profile when installed from the Windows Store.
$profilePath = "C:\Users\$Env:Username\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json"
# Remove existing comments from the profiles.json file.
$profile = (Get-Content $ProfilePath) -replace '(?m)(?<=^([^"]|"[^"]*")*)//.*' -replace '(?ms)/\*.*?\*/' | Out-String | ConvertFrom-Json
$backupProfilePath = "$home\Documents\WindowsTerminalprofiles.json"
Write-Verbose "Backing up profile to $backupProfilePath"
$profile | ConvertTo-Json | Set-Content $backupProfilePath
@scrthq
scrthq / VSCode - TokenColors.json
Created July 28, 2019 18:03
VSCode Settings to use with the One Dark Pro theme to complete colorization of PowerShell tokens and add some extra fanciness. Use with theme: https://marketplace.visualstudio.com/items?itemName=zhuangtongfa.Material-theme
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Italics",
"scope": [
"comment",
"punctuation.definition.comment",
"keyword",
"storage",
"entity.other.attribute-name",
@JustinGrote
JustinGrote / PoshGlyphs.ps1
Last active April 22, 2020 09:23
PoshGlyphs Easy to Use Special Characters
function Get-GlyphNerdFonts ($Name) {
$cache = [Runtime.Caching.MemoryCache]::Default
if ($cache['poshglyph-nfcollection']) {
$nfCollection = $cache['poshglyph-nfcollection']
} else {
[Regex]$glyphRegex = '<span><div class="class-name">(?<name>[\S<>]+)</div><div class="codepoint">(?<codepoint>\w+)</div></span>'
$glyphRegexMatches = $glyphRegex.Matches((Invoke-RestMethod -useb 'https://www.nerdfonts.com/'))
$nfcollection = [ordered]@{}
@JustinGrote
JustinGrote / New-GitIoLink.ps1
Last active February 24, 2020 21:02
Github Git.IO Link Shortener Client