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 Set-ADPrincipalRedirection { | |
param( | |
[Parameter(Mandatory)] | |
$Domain, | |
[string] | |
$ComputersOU, | |
[string] | |
$UsersOU |
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 ConvertFrom-WildcardPattern { | |
param( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[WildcardPattern]$InputObject | |
) | |
begin { | |
$pctrProp = [WildcardPattern]. | |
GetMember('PatternConvertedToRegex', [Reflection.BindingFlags]'NonPublic, Instance') | |
} |
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 New-ToastNotification | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$Title, | |
[Parameter(Mandatory=$false)] | |
[string[]]$Message, | |
[Parameter(Mandatory=$false)] |
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
class BigIntRange : System.Collections.IEnumerable | |
{ | |
[bigint]$from | |
[bigint]$to | |
[bool]$Descending | |
BigIntRange([bigint]$from,[bigint]$to) | |
{ | |
$this.from = $from |
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
class MagicNumber | |
{ | |
hidden [int] $_value | |
MagicNumber([int]$value) | |
{ | |
$this._value = $value | |
} | |
# ECMA-335 I.10.3.2 |
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 | |
Registers a HTTP prefix and listens for a HttpRequest | |
.DESCRIPTION | |
Simple PowerShell HTTP Server implementation to respond to a single HTTP request | |
.EXAMPLE | |
Get-HttpRequest -UriPrefix "http://+:80/TestUri/" -ResponseData (Get-Content C:\inetpub\wwwroot\index.html) | |
.EXAMPLE | |
Get-HttpRequest -UriPrefix "http://127.0.0.1/" -ResponseData "It Works...!" -ShowRequest | |
#> |
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
#Requires -Version 5 | |
# Define AuditSetting enum | |
[System.Flags()] | |
enum AuditSetting { | |
None = 0 | |
Success = 1 | |
Failure = 2 | |
All = 3 | |
} |
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
Get-PSReadLineOption |Get-Content -LiteralPath { $_.HistorySavePath } |ForEach-Object { | |
if($_.EndsWith('`')){ | |
$last += "{0}`r`n" -f $_.Remove($_.Length - 1) | |
}else{ | |
"${last}${_}" | |
$last = $null | |
} | |
} |Where-Object {$_ -like '*::*'} |ForEach-Object { | |
# parse history entry as powershell script |
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.Reflection | |
using namespace System.Reflection.Emit | |
using namespace System.Runtime.CompilerServices | |
# We'll attempt to construct a subset of the functionality of: | |
# public record TestRecord(int M1, string M2); | |
# | |
# Namely, we'll generate: | |
# - property getters (`get_M1()`, `get_M2()`), | |
# - a public constructor (`TestRecord(int, int);`), |