Skip to content

Instantly share code, notes, and snippets.

#Download a Dictionary as a CSV file, then pick 5 random words to return
$DictionaryURL="https://www.kaggle.com/datasets/dfydata/the-online-plain-text-english-dictionary-opted?resource=download"
$DictionaryZIP="dictionary.zip"
Invoke-WebRequest -Uri $DictionaryURL -OutFile $DictionaryZIP#
Expand-Archive $DictionaryZIP -DestinationPath .
$EnglishDictionary = import-csv -path .\OPTED-Dictionary.csv
1..5 | % { $EnglishDictionary[$(Get-Random $EnglishDictionary.Count)] | Select Word, Definition }
#Save this file to C:\Scripts\clean-iislogs.ps1
#Run this command to create the schedule task:
# schtasks /create /sc DAILY /tn "Clean IIS Logs" /tr "powershell.exe -ExecutionPolicy Bypass C:\Scripts\clean-iislogs.ps1" /rl highest /ru system /st "03:00"
$FilePath = "C:\inetpub\logs"
$FileExt = "*.log"
$maxDaystoKeep = 90
$DeleteDateTime = ((get-date).AddDays(-$maxDaystoKeep))
#Get a list of files to be deleted
alias getsecret="_getsecret"
# ~/.secrets/secrets.json !!! chmod 400
# {
# "group1": {
# "secret1":"value",
# "secret2":"value"
# },
clear-host
Echo "Keep-Alive with Scroll Lock..."
$WShell = New-Object -ComObject WScript.Shell
while ($true) {
$WShell.sendkeys("{SCROLLLOCK}")
start-sleep -milliseconds 100
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -seconds 240
}
@ByronScottJones
ByronScottJones / profile.ps1
Last active May 30, 2021 00:27
Powershell Profile
#Requires -Version 7
# Version 1.2.9
$Secrets = get-content -raw -path ~/.secrets/secrets.json | cnvertfrom-json
# check if newer version
#$gistUrl = "https://api.github.com/gists/......."
gistUrl = $Secrets.PowershellProfile.gistUrl
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
@ByronScottJones
ByronScottJones / select-capturegroup.ps1
Created March 21, 2021 19:20
Select Capture Group and return PSCustomObject
function Select-CaptureGroup {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[Microsoft.PowerShell.Commands.MatchInfo[]]$InputObject
)
begin {}
@ByronScottJones
ByronScottJones / QRCODE.C
Created March 2, 2021 02:03
ESP32 TTGO QRCODE based access
#include <TFT_eSPI.h>
#include <SPI.h>
#include "qrcode.h"
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
@ByronScottJones
ByronScottJones / Get-DeepClone.ps1
Created February 17, 2021 18:52
Powershell - Deep Clone of Hashtable
function Get-DeepClone
{
[cmdletbinding()]
param(
$InputObject
)
process
{
if($InputObject -is [hashtable]) {
$clone = @{}
@ByronScottJones
ByronScottJones / Create-iCalendar.ashx
Created January 24, 2021 05:11
Create iCal ics file with asp.net handler
<%@ WebHandler Language="C#" Class="MyNamespace.iCalendar" %>
using System;
using System.Web;
namespace MyNamespace
{
public class iCalendar: IHttpHandler
{
public bool IsReusable
{
#Requires -Version 3.0
# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM (PS Remoting) configuration and makes
# the necessary changes to allow Ansible to connect, authenticate and
# execute PowerShell commands.
#
# All events are logged to the Windows EventLog, useful for unattended runs.