This function works sort of like calling Regex.Split with this regex
\s+
let| # Assumes pwsh7 | |
| # tip: pwsh 7 added overloads | |
| $StrIn = 'Г¶' | |
| $bytes = [Text.Encoding]::GetEncoding(1252).GetBytes( $StrIn ) | |
| $Bytes = [Text.Encoding]::GetEncoding('utf-8').GetString( $bytes ) | |
| # and also | |
| $StrIn.EnumerateRunes | Ft -auto |
| function NewUser { | |
| <# | |
| .synopsis | |
| Create a new user with a name. Any "blank" values will fallback with a default value | |
| .DESCRIPTION | |
| If you use ValidateIfNotSomething, invalid or missing values throws. | |
| - Sometimes you want the command that always works, with a fallback value | |
| - $null, empty string to count as blank |
| using namespace System.Collections.Generic | |
| <# | |
| Using: Pwsh 7 | |
| Related: | |
| For parsing HTML with CSS Selector queries, see this template: <https://gist.github.com/ninmonkey/17f6a1f5b28249b6cb2ba8bc746ae4fb> | |
| #> | |
| function FindArchivedUrl { | |
| <# |
I'm experimenting with collisions for the Env var RFC: PowerShell/PowerShell-RFC#384
Case: fails as expected
$h1 = @{ "path" = 'foo\bar' }
$h2 = @{ "path`u{0}" = '' }| function InvokeWingetInstall { | |
| <# | |
| .synopsis | |
| example of using native commands with dynamic conditions. | |
| .example | |
| # example commands: Use -TestOnly and -Verbose to see cli arguments, without invoking it. | |
| InvokeWingetInstall -Verbose -Package 'Microsoft.PowerBI' -TestOnly -Silent | |
| VERBOSE: install --id Microsoft.PowerBI /silent | |
| # I'm explicitly unloading the module for each test | |
| Remove-Module ImportExcel -ea 'ignore' | |
| (Get-Module ImportExcel).IterCommands.count | |
| # out: 0 | |
| Remove-Module ImportExcel -ea 'ignore' | |
| (Get-Module ImportExcel).count | |
| # out: 0 | |
| Remove-Module ImportExcel -ea 'ignore' |
Compare if NaN fails a round trip in Powershell or when using System.Text.Json
Ran using: pwsh.exe 7.4. context