Skip to content

Instantly share code, notes, and snippets.

@webtroter
webtroter / Get-TrueNASBlockDevices.ps1
Created July 25, 2022 14:58
Gets Block device from TrueNAS Scale (uses lsblk) and displays them with powershell. Can wait for a devicename or a device count.
[CmdletBinding()]
param (
[Parameter(ParameterSetName = "SSHURI")]
[System.Uri]
$SSHURI,
#
[Parameter(ParameterSetName = "ComputerName", Mandatory)]
[string]
$ComputerName,
# Parameter help description
@webtroter
webtroter / CustomHistoryHandler.ps1
Created July 19, 2022 21:35
PowerShell Profile Sections
$CustomHistoryHandler = {
param([string]$line)
$AllowListRegex = @( # Add keywords to match that you want to allow in your history file.
"Get-TokenFromOutlook"
) -join '|'
$DenyListRegex = @( # Add keywords to match that you don't want in your history file
"correcthorsebatterystaple"
) -join '|'
@webtroter
webtroter / Disable-LegacyRightClickMenu.ps1
Last active December 18, 2024 16:20
Windows 11 Right Click Menu - Enable and Disable the old/legacy menu with PowerShell
Get-Item "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" | Remove-Item -Force -Recurse
Restart-Computer -Confirm
@webtroter
webtroter / OpenSave-FileDialogs.ps1
Last active July 3, 2024 22:13
Open/Save File Dialogs
function Get-SaveFilePath {
[CmdletBinding()]
param (
[string]
$InitialDirectory = $PWD,
[string]
$Filter
)
begin {
@webtroter
webtroter / SpotifyScratchpad.ps1
Created March 29, 2022 02:30
Change Public Playlists to Private
#Requires -Module Spotishell
# Install and setup Spotishell
# https://github.com/wardbox/spotishell
$InformationPreference = "Continue"
# Set your spotify username here
$username = "myspotifyusername"
$public_playlists = Get-UserPlaylists -Id $username | Where-Object { $_.owner.uri -eq "spotify:user:$username" -and $_.public}
@webtroter
webtroter / GenerateUsers.ps1
Last active December 1, 2021 22:21
Three function to Add/Get/Remove testing Users.
function Add-GeneratedUsers {
<#
.SYNOPSIS
Creates Generated Users
.DESCRIPTION
This function creates users automatically. Just provide some information if customization is needed
.PARAMETER Count
How many users will be created.
@webtroter
webtroter / FillDisk.ps1
Created November 30, 2021 18:29
Fill Disk
function FillDisk {
param (
$FillLimit = 20MB
)
$remaining = (Get-Volume C | Select-Object -ExpandProperty SizeRemaining) - $FillLimit
$filename = "vss-block_{0}G.dummy" -f ([math]::Round($remaining/1GB, 2))
& fsutil file createnew $filename $([math]::Floor($remaining))
}
@webtroter
webtroter / Invoke-WireGuardRoutingHelper.ps1
Last active April 3, 2025 09:11
WireGuard Windows Routing Helper Script
[CmdletBinding(DefaultParameterSetName = "PreDown")]
param (
[Parameter(ParameterSetName = "Setup")]
[switch]
$Setup,
[Parameter(ParameterSetName = "Setup")]
[switch]
$RestartWGService,
# WireGuard Interface
[Parameter(Position = 0)]
@webtroter
webtroter / sync-seedbox.sh
Created August 9, 2021 20:28
Sync Seedbox
#!/bin/bash
# Variable Section
SERVER="[email protected]"
SRC=$SERVER":/media/sdf1/username/Completed"
DEST="/media/Share/"
LOGDIR="/var/log/sync-seedbox/"
LOGFILE="/var/log/sync-seedbox/rsync_`date +%Y%m%d-%Hh%M`.log"
LOCKDIR="/var/lock/"
LOCKFILE="/var/lock/`basename $0`.lock"
@webtroter
webtroter / SophosEndpointRemovalScript.ps1
Created August 1, 2019 01:18
Sophos Endpoint Removal Script
#Sophos Endpoint Removal Script
#Usage examples:
# .\removesophos.ps1 # Just logs all messages to screen and file.ss.é
# .\removesophos.ps1 -Remove YES # Removes all Sophos components and logs all messages to screen and file.
# .\removesophos.ps1 -Password 1234567 -Remove YES # Password will be provided to SEDCli.exe if TP is on and SEDCLi.exe exists.
# .\removesophos.ps1 -ErrorOnly YES # Only print items that exist (errors) on screen. Still logs all to file.
# .\removesophos.ps1 -Remove YES -Restart YES # At the end of the process restart the computer. 10 seconds delay by default intDelaySecondsRestart.
# .\removesophos.ps1 -NoLogFile YES # No log file will be created. Messages will still be output to screen. Will run quicker.
# .\removesophos.ps1 -Debug YES # Outputs a little more data to screen for debugging purposes. Not expected to be used in normal use.