Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / Invoke-TypeClipboard.ps1
Created July 27, 2022 14:28
Invoke-TypeClipboard - Types your clipboard
<#
.SYNOPSIS
This will type the clipboard
.DESCRIPTION
This command will type the clipboard after a configurable delay, set at 2 seconds by default
.PARAMETER SecondsToSleep
Seconds to sleep before sending the clipboard
@webtroter
webtroter / Add-AdvancedSecurityToContextMenu.ps1
Last active May 16, 2024 19:28
Script to Add Advanced Security Dialog to Context Menu
<#
.SYNOPSIS
Adds (or remove) a shortcut to "Advanced Security" to Explorer's context menu.
.DESCRIPTION
Adds (or remove) a shortcut to "Advanced Security" to Explorer's context menu.
Use `-Help` for the full Help
.PARAMETER Help
@webtroter
webtroter / Invoke-WindowsShortcutHandlerManagement.ps1
Created October 11, 2022 20:38
Unregister Win+V shortcut so it can be used for something else, like Ditto
<#
.SYNOPSIS
This script can disable and enable Windows Explorer Hotkeys using the Windows Key
.DESCRIPTION
This script can disable and enable Windows Explorer Hotkeys using the Windows Key.
You cannot disable and enable with a single command. You will need to run this script
twice (once disabling, again enabling).
function Convert-FileSize {
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory = $true)]
[int64] $FileSize
)
switch ($FileSize) {