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 / PngIconConverter.ps1
Last active July 9, 2026 17:56
A simple class that converts an image to an icon in PowerShell without losing image color data, unlike System.Drawing.Icon
class PngIconConverter {
static [bool] Convert([System.IO.Stream]$input_stream, [System.IO.Stream]$output_stream, [int]$size, [bool]$keep_aspect_ratio) {
$input_bit = [System.Drawing.Bitmap]::FromStream($input_stream)
if ($input_bit -eq $null) {return $false}
if ($size -lt 1) {$size = 32}
if ($keep_aspect_ratio) {
$width = $size
$height = $input_bit.Height / $input_bit.Width * $size
} else {
$width = $height = $size
@scriptingstudio
scriptingstudio / Convert-BoundParameters.ps1
Last active July 8, 2026 12:47
Convert $PSBoundParameters to command line string
function Convert-BoundParameters ([hashtable]$parameters) {
if (-not $parameters.count) {return}
$params = [System.Text.StringBuilder]::new()
$null = $parameters.GetEnumerator().foreach{
$key,$val = $_.Key,$_.Value
if ($val -is [System.Management.Automation.SwitchParameter]) {
if ($val.IsPresent) {$params.Append(" -$key")}
}
elseif ($val -is [string]) {
if ($val.contains(' ') -or [string]::IsNullOrEmpty($val)) {$val = "'$val'"}
@scriptingstudio
scriptingstudio / hyperlink.md
Last active May 17, 2026 11:28
Work around for buggy WPF Hyperlink
using Microsoft.CSharp;
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
@scriptingstudio
scriptingstudio / ProtectedString.cs
Created April 19, 2026 18:13
Experimental C# string encryptor
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
namespace Encryption
{
public class Encryption //: IDisposable
{
@scriptingstudio
scriptingstudio / ProtectedString.ps1
Created April 19, 2026 06:57
Experimental encryption module for simple cases.
<#
.SYNOPSIS
Encrypt/decript strings.
.DESCRIPTION
AIO encryption dotsource mini-module.
The module supports AES and DPAPI encryption methods.
.FUNCTIONALITY
Encryption method: Protect-String
Decryption method: UnProtect-String
Data method: Get-CipherData
@scriptingstudio
scriptingstudio / Compress-ScriptBlock.ps1
Last active March 20, 2026 07:15
Simple PowerShell script compressor. The script works like "ConvertTo-Json -Compress". Two editions: System.Management.Automation.PSParser and System.Management.Automation.Language.Parser
<#
.SYNOPSIS
Removes comments and extra white space from an input PS script.
.DESCRIPTION
The filters omit white space and indented formatting in the output. Filters are comments, newlines, spaces, statement separator (;).
.PARAMETER Path
Specifies the path to the PS file to compress.
.PARAMETER ScriptBlock
Specifies the PowerShell scriptblock to compress.
.PARAMETER NoTest
@scriptingstudio
scriptingstudio / ps2exec.ps1
Last active July 9, 2026 08:06
Version 2. PS2EXE script deeply refactored replacing outdated techniques and overloaded logics with modern look and feel. Source compressor added to reduce output size. Source encoding, the return of the king. Implemented as a dotsource module.
#Requires -Version 5
# Insipred by and credits to PS2EXE by Markus Scholts (https://github.com/MScholtes/PS2EXE)
# Deeply refactored original code replacing outdated techniques and overloaded logics with modern look and feel. Full backward compatibility provided.
# Source compressor added to significantly reduce output size. Source encoding, the return of the king. Experimental support for PowerShell Core introduced.
<# TODO:
- remove "extract" facility (from C#)
#>
@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'