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
$ExecutionContext.InvokeCommand.CommandNotFoundAction = | |
{ | |
param([string]$commandName, | |
[CommandLookupEventArgs]$eventArgs) | |
if ($commandName -match "(.*)=(.*)") { | |
$var = $matches[1] | |
if ($var.StartsWith("get-")) { | |
$var = $var.Substring(4) | |
} |
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
<# | |
.SYNOPSIS | |
Reports if your password is pwned by querying haveibeenpwned.com | |
.DESCRIPTION | |
Query haveibeenpwned.com to see if a password has appeared in a breach. | |
The query sends the first 5 characters of the SHA1 hash, so the query should be considered safe and anonymous. |
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
# Autocompletion for clang - only works in pwsh | |
Register-ArgumentCompleter -CommandName clang -Native -ScriptBlock { | |
param($wordToComplete, $commandAst) | |
if ($wordToComplete.StartsWith('-')) { | |
$p,$a = $wordToComplete -split '=',2 | |
if ($null -ne $a) { | |
$clangArg = "$p=,$a" | |
$type = [System.Management.Automation.CompletionResultType]::ParameterValue |
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
param( | |
[Parameter(Position=0, Mandatory)] | |
[hashtable] | |
$private:Environment, | |
[Parameter(Position=1, Mandatory)] | |
$private:ScriptBlock | |
) | |
end { |
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 Microsoft.Z3 | |
using namespace System.Collections.Generic | |
using namespace System.Management.Automation.Language | |
function GetZ3Ast([System.Management.Automation.Language.Ast]$ast, $ctx) | |
{ | |
$typeName = $ast.GetType().Name | |
switch ($typeName) |
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.Management.Automation.Language | |
function AnalyzeCurlUsage | |
{ | |
param([Parameter(ValueFromPipeline)][Alias('PSPath')][string]$path) | |
process { | |
$err = $null | |
$tokens = $null |
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
<Configuration> | |
<ViewDefinitions> | |
<View> | |
<Name>MatchInfo</Name> | |
<ViewSelectedBy> | |
<TypeName>Microsoft.PowerShell.Commands.MatchInfo</TypeName> | |
</ViewSelectedBy> | |
<CustomControl> | |
<CustomEntries> | |
<CustomEntry> |
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
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class NativeConsoleMethods | |
{ | |
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | |
public static extern IntPtr GetStdHandle(int handleId); |
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
param([type]$Type) | |
$result = [pscustomobject]@{} | |
foreach ($property in $type.GetProperties([System.Reflection.BindingFlags]::Public -bor [System.Reflection.BindingFlags]::Static)) { | |
$name = $property.Name | |
$params = @{ | |
InputObject = $result | |
MemberType = 'ScriptProperty' | |
Name = $property.Name | |
} |
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 Out-Default | |
{ | |
[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=113362', RemotingCapability='None')] | |
param( | |
[switch] | |
${Transcript}, | |
[Parameter(ValueFromPipeline=$true)] |
NewerOlder