Skip to content

Instantly share code, notes, and snippets.

View santisq's full-sized avatar

Santiago Squarzon santisq

View GitHub Profile
View formdownloadasyncwithworker.ps1
Add-Type -Assembly System.Windows.Forms
$MainForm = New-Object System.Windows.Forms.Form
$MainForm.Width = 420
$MainForm.Height = 200
$MainForm.FormBorderStyle = "Fixed3d"
$MainForm.MaximizeBox = $false
$MainForm.StartPosition = "CenterScreen"
santisq / formstuff.ps1
Created November 6, 2023 20:38
winform with `.DownloadFileAsync` and progress bar
View formstuff.ps1
Add-Type -Assembly System.Windows.Forms
$form = [System.Windows.Forms.Form]@{
Size = '500, 150'
FormBorderStyle = 'Fixed3d'
$btn = [System.Windows.Forms.Button]@{
Name = 'MyButton'
View ADX Log

Setup new Azure Data Explorer Table from MyAADLogs

This document details the steps needed to create a new Azure Data Explorer table for ingested logs from Azure Active Directory.

All ingested logs from AAD are written to a table in ADX named MyAADLogs, this table is overwritten over and over thus the need to create a parsing function which is used to filter the new ingested logs by their category and construct new records out of it to then write them to their corresponding tables.

Query MyAADLogs Table

First step is to query the MyAADLogs table filtering by the record.category property and expanding those properties of interest from each record. We can query the same logs using Log Analytics for comparison. For example, for NonInteractiveUserSignInLogs:

santisq / BinarySearch.perf.ps1
Last active October 10, 2023 18:22
performance test for List<T> and Array BinarySearch Method
View BinarySearch.perf.ps1
[System.Collections.Generic.List[int]] $list = 0..10mb
[int[]] $arr = $list.ToArray()
$ran = 0..100 | ForEach-Object { Get-Random -Maximum 15mb }
$tests = @{
'Array.BinarySearch' = { [array]::BinarySearch($args[0], $args[1]) }
'Array.IndexOf' = { $args[0].IndexOf($args[1]) }
'List.BinarySearch' = { $args[0].BinarySearch($args[1]) }
'List.IndexOf' = { $args[0].IndexOf($args[1]) }
santisq / IModuleAssemblyCleanupTest.ps1
Created September 13, 2023 01:14
how to perform OnRemove in C#
View IModuleAssemblyCleanupTest.ps1
Add-Type '
using System;
using System.Management.Automation;
namespace IModuleAssemblyCleanupTest;
public class Testing : IModuleAssemblyCleanup
public void OnRemove(PSModuleInfo psModuleInfo) =>
View invokepwsh7pseudomodule.psm1
using namespace System.Diagnostics
using namespace System.Management.Automation.Runspaces
using namespace System.System.Diagnostics
using namespace System.Management.Automation
using namespace System.Management.Automation.Host
class PwshPipe : IDisposable {
[Process] $pwshProcess
[NamedPipeConnectionInfo] $pipeinfo
[powershell] $pwsh
View circularnestedalgo.ps1
using namespace System.Collections.Generic
class GroupNode {
[List[GroupNode]] $Parent = [List[GroupNode]]::new()
[string] $Group
static [Queue[GroupNode]] $Queue = [Queue[GroupNode]]::new()
[bool] IsCircularNested([hashtable] $Map) {
foreach ($parent in $this.Parent) {
View shamefulattemptatmultithreading.cs
using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Threading;
using System.Threading.Tasks;
public sealed class Pool : IDisposable
public PSDataCollection<PSObject> Output { get; } = new();
View gzipreader.cs
using System;
using System.IO;
using System.IO.Compression;
using System.Management.Automation;
using System.Reflection;
namespace Testing;
public static class Test
santisq / perftest.ps1
Last active June 23, 2023 15:18
stringbuilder vs addition assignment vs join op for strings
View perftest.ps1
$tests = [ordered]@{
'addition assignment +=' = {
$string = ''
for ($i = 0; $i -lt $args[0]; $i++) {
$string += 'A'
'join op' = {
$string = -join @(
for ($i = 0; $i -lt $args[0]; $i++) {