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
[31mhello [32mworld | |
]633;Completions? |
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(ValueFromPipeline=$true)] | |
[ValueType] | |
$profileEvent | |
) | |
begin { | |
$profileEvents = [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
param( | |
[Parameter(ValueFromPipeline)] | |
[string]$json | |
) | |
$obj = ConvertFrom-Json -InputObject $json -Depth 100 -AsHashtable | |
$location = "/" | |
function Test-Location ($path) { |
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(ValueFromPipeline)] | |
[string]$json, | |
[Parameter(Mandatory,Position=0)] | |
[string]$find | |
) | |
$obj = ConvertFrom-Json -InputObject $json -Depth 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
param($commandLine, [pscredential]$credential) | |
$csharp = @' | |
using System; | |
using System.Runtime.InteropServices; | |
public class Advapi32 | |
{ | |
[DllImport("advapi32.dll", SetLastError=true, CharSet=CharSet.Unicode)] | |
public static extern bool CreateProcessWithLogonW( |
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 System; | |
using System.Runtime.InteropServices; | |
namespace myps | |
{ | |
public static class GetProcArgv | |
{ | |
private const int CTL_KERN = 1; | |
private const int KERN_ARGMAX = 8; | |
private const int KERN_PROCARGS2 = 49; |
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
# Usage example for one commit per directory: | |
# dir -Recurse -Path . -Directory | % { $dir = $_; dir -path $dir.fullname *.cs | % { ~/test/update-code.ps1 -path $_.fullname; git add $_.fullname }; git commit -m "Update $($dir.name)" } | |
param($path) | |
$src = Get-Content $path -Raw | |
$skip = " get; set; " | |
# this matches a closing brace that is not followed by: | |
# catch, else, finally, another closing brace, newline, space, hash, slash (comment), * (comment) |
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
# adapted from https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/identifying-windows-version-part-2 | |
# download and unzip latest https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref and get these dlls from the 'lib' folder | |
Add-Type -AssemblyName ./winrt.runtime.dll | |
Add-Type -AssemblyName .\Microsoft.Windows.SDK.NET.dll | |
# define call and information to query | |
[Collections.Generic.List[System.String]]$names = 'DeviceFamily', | |
'OSVersionFull', | |
'FlightRing', |
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($file) | |
$tokens = $null | |
$err = $null | |
$file = Resolve-Path $file | |
$ast = [System.Management.Automation.Language.Parser]::ParseFile($file, [ref]$tokens, [ref]$err) | |
$commands = $ast.FindAll({$true},$true) | ? { $_ -is [System.Management.Automation.Language.CommandAst] } | % { $_.CommandElements[0].Value } | Sort-Object -Unique | |
$sources = [System.Collections.Generic.List[string]]::new() | |
$commands | % { |
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.CommandLine.Rendering | |
add-type -AssemblyName ./System.CommandLine.Rendering.dll | |
$cs = [ContainerSpan]::new( | |
[StyleSpan]::UnderlinedOn(), | |
[ForegroundColorSpan]::Green(), | |
[BackgroundColorSpan]::Yellow(), | |
[ContentSpan]::new("hello"), | |
[StyleSpan]::UnderlinedOff() |