Skip to content

Instantly share code, notes, and snippets.

View potatoqualitee's full-sized avatar
big permz energy

Chrissy LeMaire potatoqualitee

big permz energy
View GitHub Profile
@potatoqualitee
potatoqualitee / Send-Tweet.ps1
Last active July 4, 2022 09:16
Screen scraping Twitter Bot in PowerShell
# Tweet function from https://gallery.technet.microsoft.com/Send-Tweets-via-a-72b97964
workflow Send-Tweet {
param (
[Parameter(Mandatory=$true)][string]$Message
)
InlineScript {
[Reflection.Assembly]::LoadWithPartialName("System.Security")
[Reflection.Assembly]::LoadWithPartialName("System.Net")
@potatoqualitee
potatoqualitee / sys-summit-demo.ps1
Last active June 28, 2022 08:41
dbatools for systems engineers and accidental dbas
break
<#
01. Find instances
02. Connect to instances
03. Check backups
04. Check disk space
05. Perform backups
06. Check for corruption
07. Install maintenance scripts
08. Export all settings for DR
@potatoqualitee
potatoqualitee / apache-kerberos-samba-sso.txt
Last active June 12, 2022 01:31
Apache with Samba and Kerberos SSO on Ubuntu
# Install required packages (ntp keeps your clock on time)
apt-get -y install ntp ntpdate
# To add your DC to the time server list, edit /etc/ntp.conf
service ntp stop
ntpdate -s ntp.ubuntu.org
service ntp start
# install required packages
apt-get -y install krb5-user samba apache2 libapache2-mod-auth-kerb
$parms = @{
   Path        = "C:\windows\system32"
   Recurse     = $true
   ErrorAction = "SilentlyContinue"
}

Measure-Benchmark -RepeatCount 25 -Technique @{
    ForEachObject = { 
        Get-ChildItem @parms | ForEach-Object -Process {
@potatoqualitee
potatoqualitee / hugo.yml
Created February 20, 2022 20:12
github actions / hugo
name: github pages
on:
push:
branches:
- blog # Set a branch to deploy
pull_request:
jobs:
deploy:
@potatoqualitee
potatoqualitee / Invoke-WsusDbQuery.ps1
Created August 1, 2019 09:13
Create a connection to a WSUS database using PowerShell
# No longer used but didn't want to throw it away.
function Invoke-WsusDbQuery {
[CmdletBinding()]
param (
[string]$ComputerName = $script:WsusServer,
[PSCredential]$Credential = $script:WsusServerCredential,
[string]$Pattern,
[string]$UpdateId,
[switch]$EnableException
)
$MyScript = [powershell]::Create()
$null = $MyScript.AddScript( { Import-Module -Name Terminal-Icons } )
$Runspace = [runspacefactory]::CreateRunspace()
$MyScript.Runspace = $Runspace
$null = Register-ObjectEvent -InputObject $MyScript -EventName InvocationStateChanged -Action {
Import-Module -Name Terminal-Icons
}
@potatoqualitee
potatoqualitee / Invoke-Locate.ps1
Created January 25, 2015 00:14
Invoke-Locate.ps1
<#
.SYNOPSIS
Fans of (Linux/UNIX) GNU findutils' locate will appreciate Invoke-Locate, which provides similar functionality. "locate" and "updatedb" aliases are automatically created.
.DESCRIPTION
This script was made in the spirit of GNU locate. While the name of this script is Invoke-Locate, it actually creates two persistent aliases: locate and updatedb. A fresh index is automatically created every 6 hours, updatedb can be used force a refresh. Indexes generally takes less than three minutes. Performing the actual locate takes about 300 milliseconds. Invoke-Locate supports both case-sensitive, and case-insensitive searches, and is case-insensitive by default.
locate queries a user-specific SQLite database prepared by updatedb (Task Scheduler) and writes file names matching the pattern to standard output, one per line. Since the back-end is SQL, SQL "LIKE" syntax can be used for the search pattern (ie % and _). Asterisks are automatically translated to % for people who are used to searching with
@potatoqualitee
potatoqualitee / New-Logger.ps1
Last active March 3, 2022 21:10
PowerShell Async Logging using log4net.dll
function New-Logger {
$dll = Join-Path -Path $script:ModuleRoot -ChildPath log4net.dll
$null = Add-Type -Path $dll
$pattern = '[%date{yyyy-MM-dd HH:mm:ss}] [%level] [%message]%n'
$layout = [log4net.Layout.ILayout](New-Object log4net.Layout.PatternLayout($Pattern))
$dir = "C:\temp" # this is actually in my json config file
$dir = Join-Path -Path $dir -ChildPath logs
if (-not (Test-Path -Path $dir)) {
@potatoqualitee
potatoqualitee / Test-FileHash.ps1
Last active February 28, 2022 12:33
Simple file hash comparison tool written in PowerShell
function Test-FileHash {
<#
.Synopsis
This is a simple file hash comparison tool that writes to Windows Events when changes are detected
.Description
This is a simple file hash comparison tool that writes to Windows Events when changes are detected
.PARAMETER FilePath
The path to the file to hash and compare