Skip to content

Instantly share code, notes, and snippets.

View quonic's full-sized avatar

Spyingwind quonic

  • Dallas
View GitHub Profile
@quonic
quonic / Get-BashArguments.ps1
Created February 2, 2023 23:32
Parse getopt from a bash script using PowerShell.
function Get-BashArguments {
[CmdletBinding()]
[OutputType([PSObject[]])]
param(
[Parameter(Mandatory = $true)]
# Path to a bash script
[string[]]
$Path
)
@quonic
quonic / Set-StreamDeckSoundboardAudio.ps1
Last active December 1, 2024 22:21
Set-StreamDeckSoundboardAudio.ps1: A script that will allow you to change the audio Output for the Soundboard plugin for Stream Deck.
# Make sure to backup your profile, just in case that Elgato changes the file format.
# Scroll down to bottom to see example use case.
function Update-Profiles {
<#
.SYNOPSIS
Replaces outputType in all Stream Deck profiles for Elgato's Soundboard plugin.
.DESCRIPTION
@quonic
quonic / Remove-XHunter1.ps1
Created March 11, 2023 01:26
Script to automate the removal of xhunter1.sys when found. Create a scheduled task that runs at start up as admin.
#Requires -Version 5.1 -RunAsAdministrator
function Remove-XHunter1 {
param ()
Stop-Service xhunter1 -Force -NoWait -Confirm:$false
Remove-Item "HKLM:\SYSTEM\CurrentControlSet\Services\xhunter1" -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Windows\xhunter1.sys" -Force -ErrorAction SilentlyContinue
}
function Test-XHunter1 {
@quonic
quonic / Write-Log.ps1
Last active January 27, 2025 15:18
A way to standardize logging.
Function Write-Log {
<#
.SYNOPSIS
Standard Event Log entry writer
.DESCRIPTION
Writes an entry to the local system's Event Log in a predictable and dependable way.
.INPUTS
None
.OUTPUTS
None
@quonic
quonic / Start-SleepProgressBar.ps1
Last active May 28, 2023 20:06
An alternative to Start-Sleep that adds a progress bar and wait wheel using the FiraCode font. If not running in VSCode and FiraCode font is not setup, then it will fallback to ASCII.
function Start-SleepProgressBar {
<#
.SYNOPSIS
A Start-Sleep alternative that prints a progress bar with a spinning wheel at the end.
.DESCRIPTION
A Start-Sleep alternative that prints a progress bar with a spinning wheel at the end.
See: https://github.com/tonsky/FiraCode
.PARAMETER Seconds
Duration in seconds to wait.
.PARAMETER NoBar
@quonic
quonic / IsDiskSpaceLow.sh
Last active July 19, 2023 21:26
MacOS Condition on Low Disk Space. Pass a number such as 90 as an argument, and if the exit code is 1, then a drive is over 90%.
#!/usr/bin/env bash
# MacOS Condition on Low Disk Space. Pass a number such as 90 as an argument, and if the exit code is 1, then a drive is over 90%.
# This exludes any mounted dmg's, USB drives, or cdrom/dvd.
Percentage=$1
IsOver=$(df -H | grep -vE '^Filesystem|tmpfs|cdrom|loop|devfs|map| \/Volumes' | awk '{ print substr($5,1,length($5)-1) }' | awk -v p=$Percentage -F: '{if($1>p){print 1}else{print 0}}' | grep 1 | tail -n1)
exit "$IsOver"
@quonic
quonic / Get-Parameters.ps1
Created July 20, 2023 04:22
Get a PowerShell script's parameters and output certain aspects of each parameters. Utilizes the AST to get all its data.
function Get-Parameters {
param(
# Path to a .ps1 script
[string]$Path
)
begin {}
process {
$ScriptPath = Get-Item -Path $Path
$ScriptCommand = Get-Command $ScriptPath
$ScriptBlock = $ScriptCommand.ScriptBlock
@quonic
quonic / GetNewClosure.ps1
Created August 28, 2023 16:05
Understanding GetNewClosure. Assuming you have Pester installed, but not required. Remove Should parts.
# No GetNewClosure - print $a as what ever it is before printing
& {
$a = 10
$myScript = {
$a
}
& $myScript
$a = 20
& $myScript
@quonic
quonic / Preseed Debian 12
Created November 22, 2023 20:03
Preseed Provisioning Template in Forman for Debian 12. This fixes one deployment issue where the installer gets stuck trying to install python.
<%#
kind: provision
name: Preseed default
model: ProvisioningTemplate
oses:
- Debian
- Ubuntu
test_on:
- debian4dhcp
- ubuntu4dhcp
@quonic
quonic / Get-ProgramBit.ps1
Last active January 18, 2024 22:27
Get the bittness of an exe or dll.
function Get-ProgramBit {
[CmdletBinding()]
param ([string]$Path)
process {
if (-not $(Test-Path -Path $Path -ErrorAction SilentlyContinue)) {
Write-Error "Invalid Path"
return
}
$re32 = [regex]::new('PE\W\WL')
Get-Content -Path $Path -ReadCount 1 | ForEach-Object {