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
@jborean93
jborean93 / Get-CertificateTemplateInformation.ps1
Last active May 26, 2025 00:54
Gets the Certificate Template Information from an X509Certificate2 object
# Copyright: (c) 2025, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
using namespace System.DirectoryServices
using namespace System.Formats.Asn1
using namespace System.Management.Automation
using namespace System.Numerics
using namespace System.Security.Cryptography.X509Certificates
Function Get-CertificateTemplateInformation {
@it2-torchbearer
it2-torchbearer / Создание выгрузок баз.cmd
Created May 21, 2025 03:57
Скрипты создания резервных копий баз 1С Windows&Ubuntu
@echo off
rem *******************************************************************************************
rem ********************** Ввод первоначальных данных *****************************************
rem *******************************************************************************************
mode con: cp select=1251
rem Переменная пути, где будут сохраняться выгрузки из баз
rem Можно указать через ; несколько путей, в конце обязательно\
set patharcall=D:\ARC\;E:\ARC\
@dfinke
dfinke / ChatMediator.ps1
Created June 21, 2024 14:06
Demonstrates the implementation of the Mediator Design Pattern in PowerShell
<#
Define an object that encapsulates how a set of objects interact.
Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
#>
class ChatMediator {
$users
ChatMediator() {
$this.users = New-Object System.Collections.ArrayList
@dfinke
dfinke / FinanceReport.ps1
Last active July 3, 2024 17:24
PowerShell script using the Template Method pattern to generate financial reports in plain text and HTML formats. Extensible and flexible.
class ReportTemplate {
hidden $data
GenerateReport() {
$this.RetrieveFinancialData()
$this.FormatReport()
$this.SendToStakeholders()
}
RetrieveFinancialData() {
class Command {
execute() {
"[$(get-date)] Logging execute of command [$this]" | Out-Host # Logs the execution of the command
}
}
class Loony : Command {
execute() {
([Command]$this).execute() # Calls the execute method of the base class (Command)
"You're a loony." | Out-Host # Outputs "You're a loony."
@dfinke
dfinke / Logger-DecoratorPattern.ps1
Last active July 30, 2024 13:54
PowerShell Decorator Pattern: Enhance Logger with Timestamp and Uppercase
class Logger {
log($message) { # Define a method called "log" that takes a message as input
$message | Out-Host # Output the message to the console
}
}
class TimeStampingLogger : Logger { # Define a class called "TimeStampingLogger" that inherits from "Logger"
$logger # Declare a variable called "logger"
TimeStampingLogger($logger) { # Define a constructor that takes a "logger" as input
@dfinke
dfinke / ClockObserverPattern.ps1
Last active July 30, 2024 13:54
PowerShell implementation of the Observer Pattern with a Clock Timer example, featuring Digital and Analog clocks.
class Subject {
hidden [System.Collections.ArrayList]$observers
Subject() {
$this.observers = New-Object System.Collections.ArrayList
}
Attach([Observer]$o) { $this.observers.Add($o) }
@dfinke
dfinke / Try-CompositePattern.ps1
Last active July 3, 2024 17:29
Composite Pattern: Simplifies client code by treating individual objects and compositions uniformly, making it easier to work with complex structures
. .\Employee.ps1
$CEO = [Employee]::new("John","CEO", 30000)
$HeadSales = [Employee]::new("Robert","Head Sales", 20000)
$HeadMarketing = [Employee]::new("Michel","Head Marketing", 20000)
$clerk1 = [Employee]::new("Laura","Marketing", 10000)
$clerk2 = [Employee]::new("Bob","Marketing", 10000)
$salesExecutive1 = [Employee]::new("Richard","Sales", 10000)
$salesExecutive2 = [Employee]::new("Rob","Sales", 10000)
@jdhitsolutions
jdhitsolutions / PSRefresh.ps1
Last active April 24, 2025 05:04
Refresh a new Windows PowerShell Installation.
#requires -version 5.1
#requires -RunAsAdministrator
#PSRefresh.ps1
<#
Update key PowerShell components on a new Windows 10/11 installation.
This script is not intended for server operating systems. The script
should be run in an interactive console session and not in a remoting session.
@JustinGrote
JustinGrote / Update-HelpFast.ps1
Last active May 1, 2025 20:48
Update Help More Quickly using ThreadJob
#Requires -module ThreadJob
param(
#Filter modules to update by name, otherwise will update all modules
[string[]]$Name = @(),
[ValidateSet('AllUsers', 'CurrentUser')]
$Scope = 'CurrentUser',
$ThrottleLimit = 30
)
try {