This file contains 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
body *:not(code) { font-family: arial !important; } | |
code {font-family: monospace !important;} |
This file contains 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
function Get-InvocationQuote | |
{ | |
param([System.Management.Automation.InvocationInfo]$Invocation) | |
$cmdText = $Invocation.InvocationName | |
foreach($param in $Invocation.BoundParameters.GetEnumerator()){ | |
$name = $param.Key | |
$value = switch($param.Value){ | |
{$_ -is [string]} { | |
# Quote and escape all string values as sigle-quoted literals |
This file contains 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
# Z-fibonacci (or nega-fibonacci, see https://en.wikipedia.org/wiki/Fibonacci_number#Sequence_properties): | |
# F(n-2) = F(n) - F(n-1) | |
$function:fib = & { | |
$cache = [System.Collections.Generic.Dictionary[int,bigint]]::new() | |
-1..1 |Foreach-Object { | |
$cache.Add($_, $_) | |
} | |
return { |
This file contains 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
class MagicNumber | |
{ | |
hidden [int] $_value | |
MagicNumber([int]$value) | |
{ | |
$this._value = $value | |
} | |
# ECMA-335 I.10.3.2 |
This file contains 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
function ConvertTo-List | |
{ | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
[object[]]$InputObject | |
) | |
begin { | |
$list = [System.Collections.Generic.List[object]]::new() | |
} |
This file contains 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
function Fake-Progress | |
{ | |
$PSDefaultParameterValues['Write-Progress:Activity']='Making stuff up' | |
Write-Progress -Status 'Starting out' -PercentComplete 5 | |
10..45|%{ | |
Write-Progress -Status 'Doing stuff' -PercentComplete $_ | |
Start-Sleep -Milliseconds 100 | |
} |
This file contains 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
function Get-XmlFileTreeAppend | |
{ | |
param( | |
[Parameter(ParameterSetName='Path', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] | |
[string[]] | |
${Path}, | |
[Parameter(ParameterSetName='LiteralPath', Mandatory=$true, ValueFromPipelineByPropertyName=$true)] | |
[Alias('PSPath')] | |
[string[]] |
This file contains 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
function Invoke-RegexTerror | |
{ | |
[CmdletBinding(DefaultParameterSetName = 'ToBeOrNotToBe')] | |
param( | |
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] | |
[int]$Count, | |
[Parameter(ParameterSetName = 'ToBeOrNotToBe')] | |
[switch]$Shakespeare, |
This file contains 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
function Get-ADLockedOutUser { | |
[CmdletBinding(DefaultParameterSetName = 'MultiDC')] | |
param( | |
[Parameter(Mandatory = $false, ParameterSetName = 'MultiDC')] | |
[string[]]$DCFilter = @('*'), | |
[Parameter(Mandatory = $true, ParameterSetName = 'PDCOnly')] | |
[switch]$PDCOnly | |
) |
This file contains 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
using namespace System.Net.Sockets | |
using namespace System.Net.Security | |
using namespace System.Security.Cryptography.X509Certificates | |
function ConvertFrom-X509Certificate { | |
param( | |
[Parameter(ValueFromPipeline)] | |
[X509Certificate2]$Certificate | |
) |