Skip to content

Instantly share code, notes, and snippets.

View scriptingstudio's full-sized avatar
👍
Awake and ready

Matthew Gray scriptingstudio

👍
Awake and ready
  • Interstellar Systems
  • Hiranyaloka
View GitHub Profile
@scriptingstudio
scriptingstudio / ps2exe.ps1
Created March 11, 2026 07:01
PS2EXE script refactored. Source compressor added to reduce output size.
#Requires -Version 5
<#
.SYNOPSIS
Converts powershell scripts to standalone executables.
.DESCRIPTION
Converts powershell scripts to standalone executables. GUI output and input is activated with one switch,
real windows executables are generated. You may use the graphical front end Win-PS2EXE for convenience.
Please see Remarks on project page for topics "GUI mode output formatting", "Config files", "Password security",
@scriptingstudio
scriptingstudio / compare-array.ps1
Last active February 21, 2026 13:14
Yet another PS object fast comparer (2 editions)
function Compare-Array {
[CmdletBinding()]
[alias('Compare-Object2','Compare-ObjectFast')]
param (
[Parameter(Position=0)]
[psobject[]] $ReferenceObject,
[Parameter(Position=1)]
[psobject[]] $DifferenceObject,
[switch] $IncludeEqual,
[switch] $ExcludeDifferent
@scriptingstudio
scriptingstudio / Get-FolderItem.ps1
Last active February 19, 2026 07:37
Fast File Finder. Lists all files under a specified folder regardless of character limitation on path depth. Based on Robocopy.
<#
Virtual multifunction via single function without additional parameters
Get-FolderItem - list files
Remove-FolderItem - delete files
Copy-FolderItem - copy files
Move-FolderItem - move files
#>
function Get-FolderItem {
[cmdletbinding(DefaultParameterSetName='Filter')]
[alias('Remove-FolderItem','Copy-FolderItem','Move-FolderItem')] #,'rfi','cfi','mfi','gfi'
@scriptingstudio
scriptingstudio / slmgr-ps.ps1
Created February 4, 2026 06:47
SLMGR PowerShell workshop/framework to explore Windows activation management
#Requires -Version 5
<#
.SYNOPSIS
Windows Software Licensing Management Tool
.DESCRIPTION
SLMGR PowerShell workshop/framework to explore Windows activation management.
This is a ported slmgr.vbs script.
.NOTES
- Prerelease prototype
@scriptingstudio
scriptingstudio / filelocktester.ps1
Last active January 1, 2026 18:14
Simple File Lock Tester
function Test-FileLock ([string]$Path, [int]$TimeOutMs, [int]$Count) {
$timeout = $TimeOutMs
if ($timeout -lt 0) {$timeout = 0}
if ($Count -gt 0) {$Count--} else {$Count = 0}
do {
try {
$OFile = [System.IO.FileInfo]::new($Path)
$OStream = $OFile.Open([System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None)
if ($OStream) {$OStream.Close()}
return $false
@scriptingstudio
scriptingstudio / EventInfo.ps1
Last active January 10, 2026 09:22
Simple Windows Event Log Converter
# NOTE: XML doesn't take data types into account; it can be retrieved from event.Properties.Value, and the names can be taken from XML
# NOTE: Event data without names can only be retrieved from event.Properties.Value
function Convert-EventLog {
[cmdletbinding()]
[alias('cvev','Get-EventLogInfo')]
param (
[Parameter(Position=0,Mandatory,ValueFromPipeline)]
#[System.Diagnostics.Eventing.Reader.EventLogRecord[]]
[alias('inputobject')]$EventObject,
[switch]$noType, # return event data as text
@scriptingstudio
scriptingstudio / fixmac.ps1
Last active July 11, 2025 15:10
Work around for a faulty network adapter
#Requires -RunAsAdministrator
<#
There are weird computers having physical netadapters without macaddress.
This script finds faulty netadapters and assigns a random macaddress to the adapter
#>
Get-NetAdapter -Physical -ErrorAction 0 | Where-Object {
$_.InterfaceDescription -notmatch 'Wireless|wi-fi|virt|Hyper-V' -and $_.MacAddress -eq '00-00-00-00-00-00'
} | ForEach-Object {
@scriptingstudio
scriptingstudio / getremaining.ps1
Last active June 3, 2025 02:31
Get ValueFromRemainingArguments/Args as HashTable
function test-remaining {
[cmdletbinding()]
param (
[parameter(ValueFromRemainingArguments)]
$remaining
)
$htRemaining = [ordered]@{}
$unnamed = [System.Collections.Generic.list[object]]::new()
$remaining | ForEach-Object {
@scriptingstudio
scriptingstudio / testadmin.cmd
Created May 22, 2025 07:16
Culture invariant admin privileges test in cmd
powershell.exe -executionpolicy bypass -noninteractive -nologo -noprofile -command "&{ If (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {write-warning 'You must run this script as an Administrator!'; cmd.exe /c pause; exit 1000} }"
if ERRORLEVEL 1000 goto :EOF
@scriptingstudio
scriptingstudio / testleap.ps1
Last active May 18, 2025 09:11
Test leap year in one line
# But [datetime]::IsLeapYear is faster anyway
function Test-IsLeap ([uint32]$year) {
(($year * 1073750999) -band 3221352463) -le 126976
}