Skip to content

Instantly share code, notes, and snippets.

@fsackur
fsackur / ModuleFast.ps1
Created August 3, 2021 12:29 — 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
@fsackur
fsackur / Wait-LogLine.ps1
Last active July 4, 2021 01:37
Waits for lines in log files matching a pattern.
function Wait-LogLine
{
<#
.SYNOPSIS
Waits for lines in log files matching a pattern.
.DESCRIPTION
This command blocks, reading a file until a line appears that matches a pattern. If the
line matches the pattern, the entire line is written to the output stream.
@fsackur
fsackur / PowerShell.svg
Created January 16, 2021 15:30 — forked from Xainey/PowerShell.svg
SVG Vector for PowerShell logo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Relay circuit design & spec for domestic electrical heating
============================================
I have multiple Tado Smart Thermostats, model RU01, and multiple rooms with electrical underfloor heating. I require a power-switching circuit for the heating.
The heating in the largest room has a resistance of ~14 ohms and should run at 230VAC (I'm in the UK). All other rooms have higher resistance. This is a purely resistive load.
Tado do not provide great datasheets, but they have three pins for simple NO/NC/COM. I found a downloadable user guide at http://www.free-instruction-manuals.com/pdf/pa_1184164.pdf which states:
- Relay: max. 240V AC 6(4)A / max. 36V DC 6(4)A
@fsackur
fsackur / ConEmu.xml
Created February 2, 2019 07:54
ConEmu configuration for Powershell with solarized dark scheme and Ctrl-T / Ctrl-W for tabs. Save to ~\AppData\Roaming\ConEmu.xml.
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2019-02-01 21:41:26" build="180626">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{Shells::PowerShell}"/>
<value name="StartFarFolders" type="hex" data="00"/>
<value name="StartFarEditors" type="hex" data="00"/>
$Frames = (@(
" <br> <br> <br> :r:. <br> :MBBBBQBv <br> sBBBBQBBBBBQBBBU: <br> 7BQBBBQghIsBbBBBBBQB: <br> iBBBBQBBQMMgQBQBQ7MBQBj <br>
<#
When you are roughing out a C# type in powershell, and you don't want to fire up
Visual Studio, it can get tiresome having to constantly reload your script editor.
This increments the class name each time you compile it.
Blogged in https://fsackur.github.io/2018/03/30/Reflecting-on-types/
#>
$TypeDef = @'
using System;
<#
Usage:
Get-ClusterName
Get-ClusterIpAddress
Get-ClusterSqlInstanceName
#>
#Get all the DNS names used on a cluster
function Get-ClusterName {
Get-ClusterNode | select @{Name = "ClusterResource"; Expression={"Cluster Node"}}, OwnerGroup, Name, DnsSuffix
<#
.Synopsis
Provides a mapping of Windows drive letters to WWNs using inq.exe from EMC
.Description
Gets all volumes in Windows and provides device ID, drive letter and WWN.
You must have inq.exe available.
.Parameter Path
function Get-DnsCache {
<#
.Synopsis
Get entries from the DNS cache
#>
$Matches.Clear()
$DnsCache = (ipconfig /displaydns) -join "`r`n"
$Chunks = $DnsCache -split '\n\s*\r'
$Pattern = (New-Object System.Text.StringBuilder).