🧙♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| Get-ProtocolAssoc.ps1 | |
| Queries Windows for the effective handler of http/https using AssocQueryString. | |
| Compatible with Windows PowerShell 5.1 and PowerShell 7+. | |
| OUTPUT | |
| - Prints each field for http and https | |
| - Returns a PSCustomObject you can pipe to ConvertTo-Json | |
| USAGE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| Detect-DefaultBrowser.ps1 (PowerShell 5.1+ compatible) | |
| Prints step-by-step diagnostics for default browser detection (http and optional https). | |
| USAGE | |
| powershell -NoProfile -ExecutionPolicy Bypass -File .\Detect-DefaultBrowser.ps1 -Verbose | |
| .\Detect-DefaultBrowser.ps1 -IncludeHttps -TestUrl "https://example.com" | |
| .\Detect-DefaultBrowser.ps1 -TestUrl "https://example.com" -Launch | |
| #> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // HashSet supports collection initializer syntax | |
| private static readonly HashSet<string> abcCollection1 = ["a", "b", "c"]; | |
| private static readonly FrozenSet<string> abcCollection2 = ["a", "b", "c"]; // doesn't work, yet... | |
| // example with freezer: | |
| private static readonly FrozenSet<FileAttributes> allowedAttributes = Freeze(FileAttributes.Archive, FileAttributes.Device, FileAttributes.Hidden); | |
| private static readonly FrozenSet<string> allowedKeywords = Freeze(StringComparer.OrdinalIgnoreCase, "squirrel", "cat", "dog"); | |
| // example without: | |
| private static readonly FrozenSet<FileAttributes> allowedAttributesUgly = new HashSet<FileAttributes>([FileAttributes.Archive, FileAttributes.Device, FileAttributes.Hidden]).ToFrozenSet(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class ReflectionExtensions | |
| { | |
| /// <summary> | |
| /// Gets a value indicating whether property has init accessor declared. | |
| /// </summary> | |
| /// <param name="propertyInfo"></param> | |
| /// <returns>Returns <c>true</c> if the property is declared as init-only; otherwise returns <c>false</c>.</returns> | |
| public static bool IsInitOnly(this PropertyInfo propertyInfo) | |
| { | |
| if (propertyInfo == null) |