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 -Path C:\Temp\CSharpVerbalExpressions-master\VerbalExpressions\bin\Release\VerbalExpressions.dll | |
[psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::add("verbex", "CSharpVerbalExpressions.VerbalExpressions") | |
[verbex]::new().StartOfLine().Then("http").Maybe("s").Then("://").Maybe("www.").AnythingBut(" ").EndOfLine().Test("https://www.google.com") | |
$proto = [verbex]::new().StartOfLine().Then("http").Maybe("s").Then("://") | |
$Uri = $proto.AnythingBut(" ").EndOfLine() | |
$uri | |
$uri.Test("http://google.com") |
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
Black White Tie RunTime | |
----- ----- --- ------- | |
2853633 3762820 3260741 6 minutes, 45 seconds, 347 milliseconds |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<Types> | |
<Type> | |
<Name>System.String</Name> | |
<Members> | |
<ScriptMethod> | |
<Name>MarkdownStrong</Name> | |
<Script> | |
[OutputType([System.String])] | |
param() |
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
$help = Get-Help Get-Location | |
$help.Name.MarkdownHeader() | |
"Synopsis".MarkdownHeader(2) | |
$help.Synopsis | |
"Description".MarkdownHeader(2) |
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
Function Get-Parmeters { | |
[CmdletBinding()] | |
Param( | |
[string]$ComputerName, | |
[scriptblock]$ScriptBlock | |
) | |
$parameters = @{} | |
$Session = New-PSSession -ComputerName 'server' |
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
function Select-FuzzyCommand { | |
param( | |
$search='' | |
) | |
Begin { | |
$data = Get-Command | |
$search = $search.ToCharArray() -join '.*?' |
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 -Path C:\Users\chris.hunt\Downloads\PivotData\lib\NReco.PivotData.dll | |
$CSV = gc "C:\Users\chris.hunt\Downloads\PivotData\NReco.PivotData.Examples.CsvDemo\TechCrunchcontinentalUSA.csv" | ConvertFrom-Csv | |
$aggregators=new-object Collections.ArrayList | |
$aggregators.Add([NReco.PivotData.SumAggregatorFactory]::new('raisedAmt')) | Out-Null | |
$aggregators.Add([NReco.PivotData.AverageAggregatorFactory]::new('raisedAmt')) | Out-Null | |
$aggregators.Add([NReco.PivotData.MaxAggregatorFactory]::new('raisedAmt')) | Out-Null | |
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 posh-git | |
Import-Module NameIt | |
function Test-Administrator { | |
return ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") | |
} | |
##### Console Title ###### | |
$SessionTitleName = Invoke-Generate '[Adjective][Noun]' |
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
function map([scriptblock]$map, [Collections.IEnumerable]$x, $y) { $x.ForEach({& $map $_ $y}) } | |
# Two parameters | |
map { param($x, $y) $x + $y } @(1,2,3) 10 | |
# Anonymous function as a value | |
$squareIt = { param($x) $x + $x } | |
map $squareIt @(1,2,3) | |
# One parameter |
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
$customData = @{mword = echo money memory music mammoth; dword = echo data drive distance dance dude dog; adverb = echo badly carefully little much worse less more worst least most} | |
$madlib = @" | |
If you want to become [noun] literate, here are some key | |
[noun]s that you should [verb] as quickly as possible: | |
CD ROM: Stands for compact [dword]... read only | |
[mword]. This compact disc can hold as many as 600 | |
[noun]s, which is the equivalent of 700 floppy [noun]s. |