Skip to content

Instantly share code, notes, and snippets.

View AfroThundr3007730's full-sized avatar
🔧
Hacking all the things...

Eddie Carswell AfroThundr3007730

🔧
Hacking all the things...
View GitHub Profile
@AfroThundr3007730
AfroThundr3007730 / unicode_btoa_atob.js
Created July 4, 2021 02:28
Unicode string to base64 (wrapper for btoa and atob)
"use strict"
const u_btoa = str => btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_match, pl) => String.fromCharCode('0x' + pl)))
const u_atob = str => decodeURIComponent(atob(str).split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''))
@AfroThundr3007730
AfroThundr3007730 / SignScript.ps1
Last active December 9, 2024 07:21
Wrapper to Set-AuthenticodeSignature
function Set-ScriptSignature {
<# .SYNOPSIS
Wrapper function to sign and timestamp a script file #>
[Alias('SignScript')]
Param(
# The script file to sign
[Parameter(Mandatory)]
[String]$ScriptFile
)
@AfroThundr3007730
AfroThundr3007730 / Get-RunningTasks.ps1
Created March 25, 2021 20:31
Get a running list of active VITasks
function Get-RunningTasks() {
while ((Get-Task | Where-Object { $_.state -eq 'running' }).count -gt 0) {
Get-Task | Where-Object { $_.state -eq 'running' } |
Sort-Object name, percentcomplete |
Format-Table Name, State, PercentComplete, StartTime,
@{ L = 'Target'; E = { $_.ExtensionData.Info.EntityName } },
@{ L = 'Initiator'; E = { $_.ExtensionData.Info.Reason.UserName } }
Start-Sleep 10
}
}
@AfroThundr3007730
AfroThundr3007730 / Logoff-InactiveUsers.ps1
Last active March 31, 2024 19:40
Logoff inactive user sessions after 2 days
# Version 1
$idleDays = 2
$users = (((query user) -replace '^>', '') -replace '\s{2,}', ',').Trim() |
ForEach-Object {
if ($_.Split(',').Count -eq 5) {
Write-Output ($_ -replace '(^[^,]+)', '$1,')
}
else {
Write-Output $_
@AfroThundr3007730
AfroThundr3007730 / make_recursive_gdrive_download.py
Last active December 9, 2024 07:21
Generates a bash script to recursively download a Google Drive folder
#!/usr/bin/python3
# Generates a bash script to recursively download a Google Drive folder
# Original: https://gist.github.com/immuntasir/73b8e8eef7e6c9066aaf2432bebf7db0
import sys
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
@AfroThundr3007730
AfroThundr3007730 / Get-ESXiSerials.ps1
Last active March 31, 2024 18:55
Get the serial number and service tags for ESXi hosts
function Get-ESXiSerials {
<#
.SYNOPSIS
Get the serial number and service tags for ESXi hosts
#>
Param(
# Full name of host or a regex
[Parameter(Mandatory = $false)]
[string]$HostSpec
)
@AfroThundr3007730
AfroThundr3007730 / Write-ScriptEvent.ps1
Last active March 31, 2024 18:55
Wrapper to write PowerShell transcripts to the event log
function Write-ScriptEvent {
<#
.SYNOPSIS
Wrapper to write PowerShell transcripts to the event log.
#>
Param(
# Transcript file to read from
[Parameter(Mandatory = $true)]
[string]$LogFile,
# Event source to apply
@AfroThundr3007730
AfroThundr3007730 / ProfileHygiene.ps1
Last active March 14, 2021 21:50
Archives roaming profiles for deleted accounts, then deletes expired archived profiles.
# Archives roaming profiles for deleted accounts, then
# deletes old archived profiles, after retention period.
Start-Transcript C:\ProgramData\profile-hygiene.log -Append
$homePath = '\\file\User_Home$'
$profilePath = '\\file\User_Profile$'
function Remove-UserDirectory ($archivePath) {
foreach ($dir in (Get-ChildItem $archivePath)) {
@AfroThundr3007730
AfroThundr3007730 / AutoConnect-VIServer.ps1
Last active March 31, 2024 18:55
Automate PowerCLI connection to vCenter
# Automated PowerCLI connections to vCenter Server
# Script will use stored PSCredentials if user is unprivileged
function AutoConnect-VIServer () {
Param(
[string]$server = 'vcenter'
)
# Check if user is in a group with vCenter permissions
if ([System.Security.Principal.WindowsIdentity]::GetCurrent().Groups.Translate(
[System.Security.Principal.NTAccount]) -contains 'DOMAIN\vCenter_Admins') {
@AfroThundr3007730
AfroThundr3007730 / 98-vmware-modconfig.install.sh
Last active June 10, 2022 15:37
Wrapper for vmware-modconfig to sign the modules for secure boot
#!/bin/bash
# Hook to sign VMware kernel modules after kernel install
# Place at: /etc/kernel/install.d/98-vmware-modconfig.install
COMMAND="${1:-add}"
KERNEL_VER="${2:-$(uname -r)}"
SIGN_CMD="/lib/modules/$KERNEL_VER/build/scripts/sign-file"
SBSIGN_KEY='/etc/efikeys/db.key'
SBSIGN_CRT='/etc/efikeys/db.crt'