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.Collections.Generic; | |
using System.Linq; | |
using System.Management.Automation; | |
using System.Management.Automation.Language; | |
using System.Text; | |
using System.Threading; | |
[Cmdlet(VerbsOther.Use, "Object")] | |
[Alias("use")] |
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 | |
function Stop-PowerShell { | |
param( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[System.Diagnostics.Process] $Process, | |
[Parameter()] | |
[ValidateRange(1, [int]::MaxValue)] | |
[int] $TimeoutSeconds = 10) |
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.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel; | |
using System.IO; | |
using System.Management.Automation; | |
using Microsoft.PowerShell.Commands; | |
[EditorBrowsable(EditorBrowsableState.Never)] | |
public abstract class CmdletWithPathBase : PSCmdlet |
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.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Diagnostics.CodeAnalysis; | |
using System.IO; | |
using System.Management.Automation; | |
using System.Security; | |
using System.Text; | |
using Microsoft.Win32; |
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.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Timers; | |
public sealed class TitleChange : EventArgs | |
{ | |
public DateTime TimeGenerated { get; } = DateTime.Now; |
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.ComponentModel; | |
using System.Management.Automation; | |
using System.Runtime.InteropServices; | |
[Cmdlet(VerbsCommon.Get, "ShortPathName")] | |
[OutputType(typeof(string))] | |
public sealed class GetShortPathNameCommand : PSCmdlet | |
{ | |
[Parameter(Mandatory = true, Position = 0)] |
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
$ps = Split-Path $PSHOME | |
$pwsh = @( | |
Join-Path $ps '7-preview/pwsh.exe' | |
Join-Path $ps '7/pwsh.exe' | |
) | |
$script = { | |
class SizeConvert { | |
static [string[]] $Suffix = 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' |
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
## Ignore Visual Studio temporary files, build results, and | |
## files generated by popular Visual Studio add-ons. | |
benchmarks/ | |
BenchmarkDotNet.Artifacts/ | |
tools/dotnet | |
# User-specific files | |
*.suo | |
*.user |
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
Invoke-RestMethod https://gist.githubusercontent.com/santisq/bd3d1d47c89f030be1b4e57b92baaddd/raw/aa78870a9674e9e4769b05e333586bf405c1362c/Measure-Expression.ps1 | | |
Invoke-Expression | |
Add-Type @' | |
using System; | |
using System.Text; | |
public static class TestString | |
{ | |
public static string Create(string @string, int len) => |
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
Invoke-RestMethod https://gist.githubusercontent.com/santisq/bd3d1d47c89f030be1b4e57b92baaddd/raw/236c79877ebaa75ce81c1806ef568d77abad6724/Measure-Expression.ps1 | | |
Invoke-Expression | |
$range = [System.Linq.Enumerable]::Range(1, 100kb) | |
time @{ | |
'foreach + if' = { | |
param($range) | |
$result = foreach ($i in $range) { if ($i % 2) { $i } } |
NewerOlder