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 / ConvertEventLogRecord.ps1
Last active February 26, 2025 05:21
Yet Another Windows Event Log Record Expander
function Convert-EventLogRecord {
[cmdletbinding()]
[alias('clr','Format-EventLogRecord')]
param (
[Parameter(Position=0,Mandatory,ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[alias('logrecord','events')]
[System.Diagnostics.Eventing.Reader.EventLogRecord[]]$InputObject
)
@scriptingstudio
scriptingstudio / Use-Culture.ps1
Last active March 16, 2025 08:45
Culture-aware command wrapper
function Use-Culture {
param (
[System.Globalization.CultureInfo]$culture = (throw "USAGE: Use-Culture -Culture culture -Script {scriptblock}"),
[ScriptBlock]$script = (throw "USAGE: Use-Culture -Culture culture -Script {scriptblock}")
)
$OldCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture
trap {
[System.Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture
}
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
@scriptingstudio
scriptingstudio / Convert-Object.ps1
Created February 10, 2025 18:25
Array transformation function
<#
Inspired by Doug Finke's map function
https://dfinke.github.io/search%20engines/2024/11/13/Introducing-a-Custom-map-Function-in-PowerShell-for-Functional-Programming.html
#>
function Convert-Object {
[CmdletBinding()]
[alias('map')]
param (
[Parameter(Mandatory)]
$func,
@scriptingstudio
scriptingstudio / nicteam.ps1
Created September 15, 2024 15:11
NIC Team default macaddress setter
<#
.SYNOPSIS
NIC Team default macaddress setter.
.DESCRIPTION
When using DHCP reservation for NIC teaming in Windows Server there is no way of determining which member interface becomes primary at boot. Because it is impossible to determine this, we do not know which member's MAC address will be used by the team. This makes DHCP troublesome.
#>
param (
[alias('name')][string]$teamname,
[string]$macaddress,
[alias('apply')][switch]$run
@scriptingstudio
scriptingstudio / rmvmware.ps1
Last active February 17, 2025 10:51
Yet Another VMware Tools Remover
<#
.SYNOPSIS
VMware Tools Remover
.DESCRIPTION
This script will automatically rip out all VMware Tools registry entries,
files, drivers, DLLs, and services for Windows 7-11, 2008-2022.
Features:
- View/Action modes
@scriptingstudio
scriptingstudio / compress-range.ps1
Last active January 25, 2025 21:26
Simple numerical series compressor
function compress-range ([int[]]$inputobject, [switch]$sort, [switch]$unique) {
if (-not $inputobject.count) {return}
$first = $true
$range = $inputobject[0],$inputobject[0]
$param = @{}
if ($unique) {$param['unique'] = $true}
$sb = if ($sort) {{$inputobject | Sort-Object @param}} else {{$inputobject}}
foreach ($e in (.$sb)) {
$diff = [math]::Abs($e - $range[1])
if ($diff -eq 1) {$range[1]++}
@scriptingstudio
scriptingstudio / readpdf.ps1
Last active February 23, 2024 05:56
Simple PDF Reader
# https://www.nuget.org/packages/itextsharp/ (5.5.13.3)
# https://github.com/itext/itextsharp/releases/tag/5.5.13
Add-Type -Path "$psscriptroot\itextsharp.dll" # 5.5.13 and lower have no dependencies
function Read-Pdf {
[CmdLetBinding(DefaultParameterSetName="Path")]
param (
[Parameter(ParameterSetName="Path", Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, Position=0)]
[alias('fullname')][string[]]$path,
[Parameter(ParameterSetName="Instance", Position=0)]
@scriptingstudio
scriptingstudio / Join-String.ps1
Last active December 23, 2024 19:22
A missing Windows PowerShell function.
function Join-String {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]$Inputobject,
[string]$Property, [string]$Separator='',
[string]$OutputPrefix, [string]$OutputSuffix,
[switch]$SingleQuote, [switch]$DouleQuote,
[string]$FormatString
)
begin {
@scriptingstudio
scriptingstudio / ExcelQuery.ps1
Last active August 27, 2023 18:32
A simple way to get Excel content without Excel installed
<#
.SYNOPSIS
Reads data from Excel file into PowerShell object.
.DESCRIPTION
Uses OLEDB provider to execute a SQL statement against a XLSX file to read data. This cmdlet assumes a file path will be passed in and treating all results as text.
Features:
* Can read entire workbook
* Can get workbook sheet names
* Parameterized query
@scriptingstudio
scriptingstudio / psquser.ps1
Last active August 1, 2023 10:54
quser.exe PowerShell wrapper
function PSQUser {
param (
[alias('inputobject','server','srv','ipaddress')]
[string[]]$computerName = 'localhost'
)
$quserPattern = @(
'(?<UserName>>?\S+)'
'(?<SessionName>(\w+)?)'
'(?<Id>\d+)'