Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Hashbrown777 / attachsmb.ps1
Last active April 17, 2024 09:14
A set of functions that enable you to make use of multiple local SMB servers (eg ssh -L), or get explorer to interact with samba shares of other machines on non-standard ports
<#
#Required:
Install-Module -Name LoopbackAdapter -MinimumVersion 1.2.0.0
#run in admin terminal
#you do NOT need to disable/remove SMB 1.0/CIFS
#Troubleshooting:
#You can check [attempted] forwardings and [successful] listeners here, respectively
netsh interface portproxy show v4tov4
#https://serverfault.com/questions/532065/how-do-i-diff-two-folders-in-windows-powershell/1041111#1041111
Function DirDiff { Param($a, $b, [switch]$Force, [switch]$Verbose)
$a,$b `
| DiffFolders -Force:$Force -Verbose:$Verbose `
| %{
$item = $_
switch -Exact ($item.event) {
'Added' { ">`t$($item.value)" }
'Deleted' { "<`t$($item.value)" }
@Hashbrown777
Hashbrown777 / btrfs
Last active February 2, 2024 12:47
sudo btrfs filesystem usage -T /mnt/*
btrfs fi df /mnt/*
sudo btrfs device stats /mnt/*
@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 / wslMount.ps1
Last active December 3, 2023 20:13
Attach one or more physical disks to a wsl instance, using encryption and formatting options `wsl --mount` doesn't support
<# calling the wslMount function will attach one or more physical disks to a wsl instance
-drives
This parameter specifies which disks, and is an array of what Windows calls the Friendly Name.
You can see these by calling `Get-PhysicalDisk`.
-count
The list of friendly names are not necessarily unique (eg if you have multiple of the same model of drive).
Count is required so that you know how many disks have been matched, and will be passed to WSL.
-wsl
The name of the wsl install you want to interact with, defaults to the default wsl instance.
-mount
@Hashbrown777
Hashbrown777 / discordplayvideo.md
Last active November 9, 2023 09:42
play discord videos instead of downloading them
@Hashbrown777
Hashbrown777 / monitoring.sh
Last active October 27, 2023 09:02
Assorted commands
#top for networking
sudo iftop -P -B
#shows connexions going through listened port
sudo tcptrack -i eno1 port 8080
#get process listening on port
sudo netstat -tulpn | ag 8080
#top for disks
Param($file)
$file = Get-Item $file
mkvinfo $file.FullName `
| &{
Begin {
$current = $NULL
}
Process {
if (!$current) {
}
@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