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
## 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 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
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 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
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 } } |
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.Runspaces | |
using namespace System.Windows.Forms | |
using namespace System.Drawing | |
Add-Type -AssemblyName System.Windows.Forms, System.Drawing | |
$form = [Form]@{ StartPosition = [FormStartPosition]::CenterScreen } | |
$iss = [initialsessionstate]::CreateDefault2() | |
$iss.Variables.Add([SessionStateVariableEntry]::new('form', $form, '')) |
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
$PrintWindowCode = @' | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Drawing; | |
using System.Drawing.Imaging; | |
public class ScreenCapture | |
{ | |
[DllImport("user32.dll")] | |
public static extern bool GetWindowRect(IntPtr hWnd, out Rect lpRect); |
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
$map = @{ | |
color = 'red' | |
person = @{ | |
firstname = 'Bob' | |
lastname = 'Smith' | |
} | |
gender = 'his' | |
} | |
$template = @' |
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
$func = Invoke-RestMethod https://gist.githubusercontent.com/santisq/bd3d1d47c89f030be1b4e57b92baaddd/raw/73952eceb82cd31b8cb9f2fd04e2a3ef3c428110/Measure-Expression.ps1 | |
. ([scriptblock]::Create($func)) | |
time -TestCount 5 -OutputAllTests @{ | |
'TestUpdateTypeData' = { | |
class TestUpdateTypeData { | |
hidden [int] $_x | |
hidden [int] $_y | |
TestUpdateTypeData([int] $x, [int] $y) { |
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
Import-Module ActiveDirectory | |
$func = Invoke-RestMethod https://gist.githubusercontent.com/santisq/bd3d1d47c89f030be1b4e57b92baaddd/raw/73952eceb82cd31b8cb9f2fd04e2a3ef3c428110/Measure-Expression.ps1 | |
. ([scriptblock]::Create($func)) | |
$adsi = { | |
$searcher = [adsisearcher]::new( | |
'(&(objectClass=user)(objectCategory=person))', | |
[string[]] @( | |
'DistinguishedName' | |
'userAccountControl' |
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
class AppRegistration { | |
[string] $DisplayName | |
[guid] $AppId | |
[guid] $Id | |
$CreatedDateTime | |
AppRegistration([hashtable] $app) { | |
$this.DisplayName = $app['DisplayName'] | |
$this.AppId = $app['AppId'] | |
$this.Id = $app['Id'] |
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
& { | |
[CmdletBinding(DefaultParameterSetName = 'A')] | |
param( | |
[Parameter(ParameterSetName = 'A')] | |
$ParamA = 'A', | |
[Parameter(ParameterSetName = 'B')] | |
$ParamB = 'B', | |
[Parameter(Mandatory)] | |
$ParamBoth | |
) |