Skip to content

Instantly share code, notes, and snippets.

@webtroter
webtroter / Allow-PingNetFirewall.ps1
Created March 25, 2024 17:57
Add "Allow PING" to Windows Firewall
$newNetFirewallRuleSplat = @{
Name = "ICMP-Ping"
DisplayName = "Allow ICMP Ping"
Profile = 'Any'
Direction = 'Inbound'
Action = 'Allow'
Enabled = 'True'
RemoteAddress = "0.0.0.0/0"
Protocol = 'ICMPv4'
EdgeTraversalPolicy = 'Allow'
@webtroter
webtroter / Get-RobotAvatarImage.ps1
Created March 13, 2024 16:13
Obtain a Robot Avatar from Robohash.org, using a seed string
[CmdletBinding(DefaultParameterSetName="Interactive")]
param (
# Parameter help description
[Parameter(ParameterSetName="Interactive")]
[switch]
$Interactive,
[Parameter(ParameterSetName="InputString")]
[string]
$InputString,
# Set
@webtroter
webtroter / Invoke-UpdateAndLaunchDrawIO.ps1
Created January 18, 2024 23:19
Check and Update Draw IO Desktop No Install for Windows
#Requires -Version 7
[CmdletBinding(DefaultParameterSetName = "Check")]
param (
# Check Switch
[Parameter(ParameterSetName="Check", Mandatory)]
[Parameter(ParameterSetName="CheckAndUpdate")]
[switch]
$Check,
@webtroter
webtroter / Move.ps1
Created December 5, 2023 00:25
Move files with date in a date subfolder
# Execute this PowerShell from inside your directory.
# Adjust the pattern based on your needs. Don't include the extension
# Filename for this pattern : Replay_2023-12-01_21-04-14.mp4
$pattern = "Replay_(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})_(?<hour>\d{2})-(?<minute>\d{2})-(?<second>\d{2})"
Get-ChildItem -Filter "*.mp4" | % {
if ($_.Basename -match $pattern) {
$Matches.Remove(0)
$filedate = Get-Date @Matches
@webtroter
webtroter / Copy-ACLFromTemplateToTarget.ps1
Last active November 30, 2023 17:49
Small script to copy the ACE matching a group from a Template directory to a target Directory (and only this one, no descendant)
<#
.SYNOPSIS
To add the File Shares Operators in the ACL with the template permissions on a single directory
.DESCRIPTION
Ce script ajoute l'entrée pour le groupe 'File Shares Operators'(ou le groupe spécifié) dans les ACL du répertoire choisi
afin que celui-ci puis gérer les permissions sans lire le contenu.
This Script adds ACEs that allows a FileSharesOperators Group to manages the ACL on the directory without allowing
the group to read the content of files.
function Convert-FileSize {
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory = $true)]
[int64] $FileSize
)
switch ($FileSize) {
@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).
@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-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 / 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