Skip to content

Instantly share code, notes, and snippets.

@DerfJagged
DerfJagged / Get_Dates_for_Upcoming_Weekdays.ps1
Created November 7, 2024 17:27
Get Dates for Upcoming Weekdays
$currentDate = Get-Date
$currentDate9am = $currentDate.Date.AddHours(9)
$weekendDaysEncountered = 0
$nextDayOccurrance = @("NULL","NULL","NULL","NULL","NULL")
for ($i = 0; $i -le 7; $i++) {
$targetDate = $currentDate9am.AddDays($i)
Write-Host $target-Date.DayOfWeek
switch ($targetDate.DayOfWeek) {
'Monday' {$nextDayOccurrance[0] = $targetDate.ToString("MM/dd")}
'Tuesday' {$nextDayOccurrance[1] = $targetDate.ToString("MM/dd")}
@DerfJagged
DerfJagged / Run_PowerShell_Script_from_ToastNotification.ps1
Created November 7, 2024 16:27
Run PowerShell Script from Windows ToastNotification
This example shows a toast with a button for each day of the week. When selected, it runs a script called WindowsUpdatePS1.ps1, passing it the day of the week as an argument.
You have to create a registry entry for this.
<toast>
...
<actions>
<action content="Mon" arguments="ToastUpdateWindows:,Monday" activationType="protocol" />
<action content="Tues" arguments="ToastUpdateWindows:,Tuesday" activationType="protocol" />
<action content="Wed" arguments="ToastUpdateWindows:,Wednesday" activationType="protocol" />
<action content="Thurs" arguments="ToastUpdateWindows:,Thursday" activationType="protocol" />
@DerfJagged
DerfJagged / Rename_Windows_Profile_in_Registry.ps1
Created November 2, 2024 04:26
Rename Windows Profile in Registry
# Script to change all registry entries containing old username to new username.
#
# 1. Create a second admin account on your PC
# 2. Log out of your primary account and into the secondary account
# 3. Rename profile via Control Panel > User Accounts
# 4. Rename old username in C:\Users\ to new username
# 5. Change the two variables below and run the script in Admin PowerShell. It will take a long time.
# 6. Log into the renamed profile and run the script again. This will change the registry entries that may be only editable by the owner account.
# Define the old and new user paths
@DerfJagged
DerfJagged / Delete_Duplicate_Files.py
Created November 1, 2023 02:10
MediaWiki Delete Duplicate Files Script
#!/usr/bin/python3
import requests
import json
import mwclient
################### CONFIGURE ME ###################
site = mwclient.Site('YOUR_WEBSITE.com', path='/wiki/')
site.login(username='USERNAME_HERE', password='PASSWORD_HERE')
URL = "https://YOUR_WEBSITE.com/wiki/api.php"