Skip to content

Instantly share code, notes, and snippets.

@mklement0
mklement0 / ConvertTo-BodyWithEncoding.ps1
Last active September 7, 2023 18:55
PowerShell function that converts the raw body of a web-request response to a string based on the given character encoding.
<#
Prerequisites: Window PowerShell v5.1 and PowerShell (Core), on all supported platforms. (May work in earlier versions.)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and INSTANT DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/209a9506b8ba32246f95d1cc238d564d/raw/ConvertTo-BodyWithEncoding.ps1 | iex
@mklement0
mklement0 / Debug-String.ps1
Last active August 24, 2023 06:40
PowerShell function to visualize control characters and Unicode characters in strings
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <mklement0@gmail.com>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/7f2f1e13ac9c2afaf0a0906d08b392d1/raw/Debug-String.ps1 | iex
function Reset-ADPassword {
[CmdletBinding(SupportsShouldProcess)]Param(
[Parameter(Position=0,Mandatory)]
[String]
$UserName,
[Parameter(Position=1)]
[String]
$Domain = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).Name,
@thegooddoctorgonzo
thegooddoctorgonzo / Migrate-ScheduledTasks.psm1
Last active September 28, 2023 14:54
Migrates scheduled tasks created by specified users and scripts from old server to new server. Also replaces all references to old server in ps1 files with new server name and disables those tasks on retired server.
# PowerShell function: Move scheduled tasks from old server to new server
# Author: thegooddoctorgonzo 20180424
Function Migrate-ScheduledTasks {
<#
.SYNOPSIS
Migrates scheduled tasks created by specified users and scripts from old server to new server. Also replaces all references to old server in ps1 files with new server name
.DESCRIPTION
Migrates scheduled tasks created by specified users and scripts from old server to new server. Also replaces all references to old server in ps1 files with new server name
.EXAMPLE
Move-ScheduledTasks -OldServer Serv1 -NewServer Serv2 -Authors domain\user -MoveScripts
@mwinckler
mwinckler / plex_season_rename_bookmarklet.js
Last active April 27, 2020 16:12
Bookmarklet to rename TV show seasons in Plex
javascript:(function() { var input = document.createElement('input'); input.setAttribute('type', 'hidden'); input.setAttribute('name', 'title'); input.setAttribute('value', prompt('New title:')); document.getElementById('lockable-summary').parentNode.appendChild(input); })();
@consti
consti / hosts
Last active April 23, 2024 19:50
/etc/hosts to block shock sites etc.
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#<localhost>
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
255.255.255.255 broadcasthost
::1 localhost
@ser1zw
ser1zw / dragdrop.ps1
Created March 22, 2012 17:48
PowerShell Drag & Drop sample
# PowerShell Drag & Drop sample
# Usage:
# powershell -sta -file dragdrop.ps1
# (-sta flag is required)
#
Function DragDropSample() {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.text = "Drag&Drop sample"
$listBox = New-Object Windows.Forms.ListBox