Skip to content

Instantly share code, notes, and snippets.

View asheroto's full-sized avatar
😎

asheroto

😎
  • United States
View GitHub Profile
@asheroto
asheroto / Set-EnvironmentVariable.ps1
Last active August 3, 2024 09:06
Functions to instantly get, set, or delete an environment variable. Bypasses the typical delay experienced with Environment.SetEnvironmentVariable, which can be slow due to its broadcasting a message to all top-level windows. These functions offer a more efficient alternative for getting, setting, or deleting environment variables.
# See this for more info:
# https://stackoverflow.com/questions/4825967/environment-setenvironmentvariable-takes-a-long-time-to-set-a-variable-at-user-o
function Set-EnvironmentVariable {
<#
.SYNOPSIS
Instantly sets an environment variable in the machine or user environment by updating the registry.
.DESCRIPTION
Instantly sets an environment variable in the machine or user environment by updating the registry.
@asheroto
asheroto / Get-OSInfo.ps1
Last active January 7, 2026 19:51
Get-OSInfo is a PowerShell function that retrieves key details about the Windows OS, including Release ID, Display Version, Name, Type (Workstation/Server), Numeric Version, Edition ID, Version (an object that includes major, minor, and build numbers), and Architecture (OS architecture, not processor architecture).
function Get-OSInfo {
<#
.SYNOPSIS
Retrieves detailed information about the operating system version and architecture.
.DESCRIPTION
This function queries both the Windows registry and the Win32_OperatingSystem class to gather comprehensive information about the operating system. It returns details such as the release ID, display version, name, type (Workstation/Server), numeric version, edition ID, version (object that includes major, minor, and build numbers), and architecture (OS architecture, not processor architecture).
.EXAMPLE
Get-OSInfo
@asheroto
asheroto / Webroot-Poll.cmd
Created June 26, 2023 23:23
Trigger Webroot (WRSA.exe) to poll the server for updates or policy changes.
@echo off
:: Relaunch script as admin if needed
NET FILE > NUL 2>&1 || POWERSHELL -ex Unrestricted -Command "Start-Process -Verb RunAs -FilePath '%ComSpec%' -ArgumentList '/c \"%~fnx0\" %*'" && EXIT /b
:: Code
echo.
if exist "C:\Program Files (x86)\Webroot\WRSA.exe" "C:\Program Files (x86)\Webroot\WRSA.exe" -poll & echo POLLED: "C:\Program Files (x86)\Webroot\WRSA.exe"
if exist "C:\Program Files\Webroot\WRSA.exe" "C:\Program Files\Webroot\WRSA.exe" -poll & echo POLLED: "C:\Program Files\Webroot\WRSA.exe"
echo.
@asheroto
asheroto / chocolatey.log
Created May 17, 2023 08:12
PowerToys installer issue with Chocolatey
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileName = "$toolsDir\PowerToysSetup-0.68.1-x64.exe"
$version = "0.68.1"
$WindowsVersion=[Environment]::OSVersion.Version
if ($WindowsVersion.Major -ne "10") {
throw "This package requires Windows 10."
}
$IsCorrectBuild=[Environment]::OSVersion.Version.Build
@asheroto
asheroto / Detect-Browser-or-CLI-Based-UserAgent.php
Last active April 24, 2023 11:00
Using PHP, detect if a visitor browser based or command line based connection. Does not differentiate between desktop and mobile browsers. Not a definitive list of user agents.
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$browsers = array(
'Firefox', 'Chrome', 'Safari', 'Opera', 'Internet Explorer', 'Edge', 'Android Browser', 'Samsung Internet', 'UC Browser', 'Yandex Browser', 'Brave', 'Vivaldi', 'Maxthon', 'SeaMonkey', 'Pale Moon', 'Mozilla', 'Netscape', 'Konqueror', 'Epiphany', 'Midori', 'Links', 'Lynx', 'w3m', 'Dillo', 'iCab', 'OmniWeb', 'Camino', 'Shiira', 'Flock', 'Galeon', 'K-Meleon', 'SlimBrowser', 'GreenBrowser', 'Avant Browser', 'Iron', 'RockMelt', 'Comodo Dragon', 'Coowon', 'Sleipnir', 'Sputnik Browser', 'Maxthon Nitro', 'Cyberfox', 'Waterfox', 'Basilisk', 'Iridium', 'Puffin', 'Tor Browser'
);
$cliBased = array(
'Advanced REST Client', 'Agouti', 'Andoid Debug Bridge (adb)', 'ANTs p2p', 'Apache JMeter', 'ApacheBench', 'aria2', 'aria2c', 'asciinema', 'axel', 'blackfire', 'BlackWidow', 'browsh', 'cadaver', 'clamav-milter', 'Clink', 'curl', 'cURLie', 'davix', 'davtest', 'DirBuster', 'Drupwn', 'DVCS-autosync', 'dwdiff', 'el-get', 'elinks', 'etckeeper', 'FastHttp', 'feed
@asheroto
asheroto / CommandLine-UserAgents
Last active April 24, 2023 10:37
List of well known command line based user agents
Advanced REST Client
Agouti
Andoid Debug Bridge (adb)
ANTs p2p
Apache JMeter
ApacheBench
aria2
aria2c
asciinema
axel
@asheroto
asheroto / 1-Windows-Setup-TPM-Bypass-Internet-Bypass.md
Last active May 7, 2026 02:49
Windows setup answer file working on Windows 11. Skips OOBE (EULA, networking) and pretty much everything else during normal setup.

Windows 10/11 Setup Answer File + TPM Bypass + CPU requirement + storage requirement + Internet requirement bypass + disable BitLocker automatic encryption

This is a Windows setup answer file working on Windows 10 and 11.

What it does:

  • Skips OOBE (EULA, networking) and pretty much everything else during normal setup
  • Sets Keyboard + Language to English (US)
  • Set timezone to Central Standard Time
  • Creates user "User" with password of "password"
@asheroto
asheroto / Check-For-PowerShell-Invoke-Command.ps1
Created June 30, 2022 01:29
PowerShell script to check for the presence of Invoke-Command, such as that ran by Empire and other fileless malware.
$result = Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-Sysmon/Operational"; StartTime=(get-date).AddHours(-1); EndTime=(Get-Date); ID=1}| ?{$_.Message -match "Invoke-Command" }
if($result.Count -gt 0) {
# PUT YOUR SCRIPT ACTION HERE WHEN DETECTED IN THE LAST HOUR
}
@asheroto
asheroto / Sort-Custom.md
Last active March 16, 2023 13:23
Sort/alphabetize a custom PowerShell object by property name such as when using a command line Get-Host.

Sort-Custom

Sort/alphabetize a custom PowerShell object by property name such as when using a command line Get-Host.

Example

Before:

PS C:\> Get-Host

Name : ConsoleHost

@asheroto
asheroto / RenameComputerToServiceTag.ps1
Last active October 30, 2025 01:18
Rename a Dell computer to the computer's service tag
#Requires -RunAsAdministrator
# Get Dell Service Tag
# If empty or serial number is greater than 7 characters, exit script
$serial = (get-wmiobject win32_systemenclosure | select serialnumber).serialnumber
if ($serial.length -eq 0 -or $serial.length -gt 7) { Write-Output "Service tag not detected! Failed rename."; exit; }
Write-Output "Dell Service Tag: $serial"
Write-Output ""
# Rename