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
private static void InvokePowerShell(IDictionary<string, object> env, StreamWriter w) | |
{ | |
string req = env["owin.RequestQueryString"] as string; | |
var queryParts = HttpUtility.ParseQueryString(req); | |
var powerShellFilename = queryParts[null] + ".ps1"; | |
if (File.Exists(powerShellFilename)) | |
{ | |
var script = File.ReadAllText(powerShellFilename); |
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
param($data=1..50) | |
$xl = New-Object -ComObject Excel.Application | |
$xlProcess = Get-Process excel | |
$wf = $xl.WorksheetFunction | |
$data = $data|iex | |
New-Object PSObject -Property @{ | |
Median = $wf.Median($data) |
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 Invoke-Csx { | |
param($script = 'System.Console.WriteLine("Hello World");') | |
foreach($dll in (dir .\lib)) { Add-Type -Path $dll.FullName} | |
$engine = New-Object Roslyn.Scripting.CSharp.ScriptEngine $null, $null | |
$engine.AddReference("System") | |
$engine.AddReference("System.Core") | |
$session = $engine.CreateSession() |
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
$sb = { | |
$node = "node.exe" | |
if(!(Get-Command $node -ErrorAction SilentlyContinue)) { | |
throw "Could not find $node" | |
} | |
$psISE.CurrentFile.Save() | |
& $node $psISE.CurrentFile.FullPath | |
} |
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 Get-ContentJson { | |
<# | |
.Synopsis | |
Get-ContentJson reads a json file, converts it an returns the object | |
.Example | |
ls . -recurse *.json | Get-ContentJson | |
.Example | |
Get-ContentJson (dir . *.json).fullname | |
#> | |
param( |
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 Write-HostWithTimestamp { | |
param($Message) | |
Write-Host "[$((Get-Date).ToString('yyyyMMddhhmmss'))] $Message" | |
} | |
function Get-TestJS { | |
param( | |
[Parameter(Mandatory)] | |
$LanguageIdentifier |
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
$json=" | |
{ | |
'name': 'john doe', | |
'age':10, | |
'pets': [] | |
} | |
" | |
$json | | |
ConvertFrom-Json | |
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 MyISE { | |
param($File) | |
if(!(Test-path $File)) { | |
New-Item -name $File -itemtype "file" | |
} | |
ise $file | |
} |
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 Get-CitiBikeStations { | |
param($label) | |
$wc = New-Object net.webclient | |
($wc.DownloadString("http://appservices.citibikenyc.com/data2/stations.php") | | |
ConvertFrom-Json).results | | |
select label, availableBikes,availableDocks | | |
where label -Match $label | |
} |
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
$svninfo = @{} | |
svn help | | |
?{$_ -match "^ "} | | |
%{($_.trim() -split " ")[0]} | | |
%{ | |
$command = $_ | |
if(!$svninfo.ContainsKey($command)) { | |
$svninfo.$command=@{SingleHyphen=@();DoubleHyphen=@()} | |
} |