Skip to content

Instantly share code, notes, and snippets.

Avatar
🔧
Hacking all the things...

Eddie James Carswell II AfroThundr3007730

🔧
Hacking all the things...
View GitHub Profile
@AfroThundr3007730
AfroThundr3007730 / SignScript.ps1
Created Mar 30, 2021
Wrapper to Set-AuthenticodeSignature
View SignScript.ps1
function SignScript() {
Param(
[string]$file
)
Set-AuthenticodeSignature -FilePath $file -Certificate `
(Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert)[0] `
-TimestampServer 'http://timestamp.digicert.com'
}
@AfroThundr3007730
AfroThundr3007730 / Get-RunningTasks.ps1
Created Mar 25, 2021
Get a running list of active VITasks
View Get-RunningTasks.ps1
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 Apr 19, 2021
Logoff inactive user sessions after 2 days
View Logoff-InactiveUsers.ps1
# 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 Feb 9, 2021
Generates a bash script to recursively download a Google Drive folder
View make_recursive_gdrive_download.py
#!/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 Feb 5, 2021
Get the serial number and service tags for ESXi hosts
View Get-ESXiSerials.ps1
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 Mar 8, 2021
Wrapper to write PowerShell transcripts to the event log
View Write-ScriptEvent.ps1
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 Mar 14, 2021
Archives roaming profiles for deleted accounts, then deletes expired archived profiles.
View ProfileHygiene.ps1
# 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 Mar 30, 2021
Automate PowerCLI connection to vCenter
View AutoConnect-VIServer.ps1
# 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 Feb 18, 2021
Wrapper for vmware-modconfig to sign the modules for secure boot
View 98-vmware-modconfig.install.sh
#!/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'
@AfroThundr3007730
AfroThundr3007730 / decrypt_gnupg-sc.sh
Created Jul 20, 2020
Modified version of Debian's cryptsetup hook for GnuPG Smartcard unlock
View decrypt_gnupg-sc.sh
#!/bin/sh
if [ -d "/cryptroot/gnupghome" ]; then
export GNUPGHOME="/cryptroot/gnupghome"
fi
run_gpg() {
/usr/bin/gpg --no-options --trust-model=always "$@"
}
decrypt_gpg () {