Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Hashbrown777 / audioTabBbCode.ps1
Last active July 6, 2023 13:35
Grab all music metadata and output it in bbcode
. './metadata.ps1'
Function Bbcode-Row {
Param ([switch]$Heading, $From)
Begin {
'[tr]'
}
Process {
('[th]','[td]')[!$Heading]
if ($From) {
@Hashbrown777
Hashbrown777 / #WSL stuff
Last active August 28, 2023 07:57
wsl stuff
#todo explanation
@Hashbrown777
Hashbrown777 / dedupe.ps1
Last active March 9, 2021 23:05
Deduplicates identical files with preferences for which filenames to choose between the options.
$dirs='.'
Get-ChildItem -Path 'dedupe' | Remove-Item -Recurse
$dirs = $dirs | %{ ($_ | Get-Item).FullName }
$matchDirs = '^(' + (($dirs | %{ [Regex]::Escape($_) }) -join '|') + ')'
$preferences = (
('Act \d{4}( No \d+| \(\d{4} No[. ]\d+\))? - \d{1,2}\.\d{1,2}\.\d{4}\.pdf$', 'Act,( \d{4},?)?( No \d+| \(\d{4} No[. ]\d+\))? - \d{1,2}\.\d{1,2}\.\d{4}\.pdf$' ),
('Act \d{4} No \d+ - \d{1,2}\.\d{1,2}\.\d{4}\.pdf$' , 'Act( No \d+)? - \d{1,2}\.\d{1,2}\.\d{4}\.pdf$' ),
('Act \d{4} No \d+ - \d{1,2}\.\d{1,2}\.\d{4}\.pdf$' , 'Act,? \d{4},? No\.\d+ - \d{1,2}\.\d{1,2}\.\d{4}\.pdf$' ),
@Hashbrown777
Hashbrown777 / romannumerals.ps1
Last active April 12, 2021 04:14
The most succinct and elegant hardly-hard-coded [standard]RomanNumeral converter you've probably ever seen
Filter FromRoman {
$output = 0
if ($_ -notmatch '^(M{1,3}|)(CM|CD|D?C{0,3}|)(XC|XL|L?X{0,3}|)(IX|IV|V?I{0,3}|)$') {
throw 'Incorrect format'
}
$current = 1000
$subtractor = 'M'
$whole = $False
@Hashbrown777
Hashbrown777 / emails.ps1
Last active June 15, 2021 06:39
Gets all your unread emails from all your accounts and subdirectories in outlook and presents them to you in a table
. ./async.ps1
. ./asynclet.ps1
. ./unicode.ps1
. ./windows.ps1
. ./wrap.ps1
$_TABLE_TITLE = 'The powershell window will show progress. You can email or run again by making a selection'
$timer = [system.diagnostics.stopwatch]::StartNew()
$selection = [Asynclet]::new(
'Out-GridView',
@Hashbrown777
Hashbrown777 / 1_client.ps1
Last active December 17, 2023 11:36
Listen and send basic messages over TCP to see if your ports are open
&{ Param($hostname, $port)
$socket = $NULL
$stream = $NULL
try {
$socket = [System.Net.Sockets.TCPClient]::new(
[System.Net.IPAddress]::Parse(
[System.Net.Dns]::GetHostAddresses($hostname)
),
$port
)
@Hashbrown777
Hashbrown777 / $Utilities.ps1
Last active October 16, 2023 16:14
Useful utils for pwsh
#just to name the gist as per https://stackoverflow.com/a/19904644/2518317
@Hashbrown777
Hashbrown777 / selfElevate.ps1
Created March 26, 2021 11:39
when put at the top of a script ensures it is [re]ran as admin
#at top of script
if (!
#current role
(New-Object Security.Principal.WindowsPrincipal(
[Security.Principal.WindowsIdentity]::GetCurrent()
#is admin?
)).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
) {
@Hashbrown777
Hashbrown777 / ServerCheck.ps1
Last active April 12, 2021 04:06
Give a detailed report on the ping and tcp status of servers.
#recognised protocols
$protocols=@{
http =80 ;
https=443;
}
$names=@{
teratext='Content Server';
smb ='Network share' ;
ssh ='Remote shell' ;
rdp ='Remote desktop';
let bob = () => {
let count = 0;
for (let e of Array.from(document.querySelectorAll('.NotificationItem__clearIconButton___3pU15'))) {
e.click();
++count;
}
if (count)
setTimeout(bob, 5000);
};
bob();