This file contains hidden or 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
static unsafe void ToTitleCase(string input) | |
{ | |
if (input.Length == 0) | |
{ | |
return; | |
} | |
fixed (char* chars = input) | |
{ | |
bool startOrNotLetter = true; |
This file contains hidden or 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.ComponentModel; | |
using System.Runtime.InteropServices; | |
namespace HandleStuff | |
{ | |
public class SystemHandle | |
{ | |
private readonly SYSTEM_HANDLE _handle; |
This file contains hidden or 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
New-Module TestModule { | |
function Test-InvokeUsingCmdlet { | |
[CmdletBinding()] | |
param( | |
[Parameter(ValueFromPipeline)] | |
[psobject] $InputObject, | |
[Parameter(Mandatory, Position = 0)] | |
[scriptblock] $Scriptblock | |
) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel; | |
using System.IO; | |
using System.Management.Automation; | |
using System.Runtime.InteropServices; | |
using Microsoft.PowerShell.Commands; |
This file contains hidden or 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' |
NewerOlder