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 / 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 August 26, 2024 14:20
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 July 24, 2024 09:40
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 February 28, 2024 02:54
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+)'
@scriptingstudio
scriptingstudio / dhcplog.ps1
Created July 5, 2023 15:14
DHCP Log Viewer
<#
Event ID Meaning
00 The log was started.
01 The log was stopped.
02 The log was temporarily paused due to low disk space.
10 A new IP address was leased to a client.
11 A lease was renewed by a client.
12 A lease was released by a client.
13 An IP address was found to be in use on the network.
14 A lease request could not be satisfied because the scope's address pool was exhausted.
@scriptingstudio
scriptingstudio / arrayshift.ps1
Last active July 4, 2024 14:03
Concept demo: array shift
<#
$step < 0 - left shift
$step = 0 - reverse
$step > 0 - right shift
#>
function Shift-Array {
[cmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
$Inputobject,
@scriptingstudio
scriptingstudio / ConvertTo-HtmlTable.ps1
Last active May 14, 2024 09:18
Simple and robust PowerShell object to HTML table converter that just works
<#
.SYNOPSIS
Creates HTML table from .NET objects.
.DESCRIPTION
This is basic cmdlet, as a helper, to build HTML tables for complex HTML content.
Converts .NET objects into HTML that can be displayed in a Web browser.
This cmdlet works like "ConvertTo-Html -Fragment" but does not have any of its disadvantages, allowing HTML entities in cells, omiting the first column colons and allowing multi-column tables in the List mode, etc.
Features:
- Parameterset autoresolve. There are no predefined parameter sets
- Input data preprocessor: sorting and filtering