Skip to content

Instantly share code, notes, and snippets.

View santisq's full-sized avatar

Santiago Squarzon santisq

View GitHub Profile
@santisq
santisq / ModuleFast.ps1
Created January 13, 2022 04:13 — forked from JustinGrote/ModuleFast.ps1
A high performance Powershell Gallery Module Installer
#requires -version 5
<#
.SYNOPSIS
High Performance Powershell Module Installation
.DESCRIPTION
This is a proof of concept for using the Powershell Gallery OData API and HTTPClient to parallel install packages
It is also a demonstration of using async tasks in powershell appropriately. Who says powershell can't be fast?
This drastically reduces the bandwidth/load against Powershell Gallery by only requesting the required data
It also handles dependencies (via Nuget), checks for existing packages, and caches already downloaded packages

A small collection specialised scripts for Active Directory.

Includes:

  • Compare-ADMemberOf
  • Get-ADSystemInfo
  • Get-GroupMemberTree
  • Get-LdapObject
  • Get-MemberOfTree
  • Test-LdapSslConnection
@santisq
santisq / Time-Command.ps1
Created May 25, 2022 21:22 — forked from mklement0/Time-Command.ps1
PowerShell function that times the execution of one or more commands, averaged over a specifiable number of runs.
<#
Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions)
License: MIT
Author: Michael Klement <[email protected]>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/9e1f13978620b09ab2d15da5535d1b27/raw/Time-Command.ps1 | iex
function Test-RpcPort {
<#
.SYNOPSIS
Enumerates and tests connectivity to the RPC ports on the target server.
.DESCRIPTION
Enumerates and tests connectivity to the RPC ports on the target server.
Rebuilt from https://gallery.technet.microsoft.com/Test-RPC-Testing-RPC-4396fcda
#>
@santisq
santisq / Clean-File-Demo.ps1
Created June 15, 2022 16:04 — forked from indented-automation/Clean-File-Demo.ps1
Removes trailing null data from the end of a file
$Path = 'c:\temp\test.long'
$content = [Byte[]]::new(50MB)
[Array]::Copy(
[Byte[]][Char[]]'Hello world',
0,
$content,
10,
11
)
@santisq
santisq / Get-FileEncoding.ps1
Created November 1, 2022 14:18 — forked from indented-automation/Get-FileEncoding.ps1
Signature-based encoding detection
using namespace System.Collections.Generic; using namespace System.Linq
function Get-FileEncoding {
<#
.SYNOPSIS
Attempt to determine a file type based on a BOM or file header.
.DESCRIPTION
This script attempts to determine file types based on a byte sequence at the beginning of the file.
If an identifiable byte sequence is not present the file type cannot be determined using this method.
using module ActiveDirectory
using namespace System.Reflection
function Convert-ADFilter {
<#
.SYNOPSIS
Converts PowerShell-style filters used by the AD module into LDAP filters.
.DESCRIPTION
Convert-ADFilter uses the QueryParser from the AD module to convert PowerShell-style filters into LDAP