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
#region new() | |
# new() works not only on PS Classes, but wraps existing .NET ctors as well: | |
[System.Net.WebProxy]::new("proxyserver.contoso.com",3128) | |
#endregion | |
#region Add-Type | |
#region Access modifiers |
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([string]$VMNameStr) | |
# Trim whitepsace on input string, | |
# then split at commas (surrounded by 0 or more whitespace chars on each side) | |
$VMNameStr.Trim() -split "\s*,\s*" |
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
gci Test*|select @{Name="Path";Expression={[regex]::Replace($_.FullName,"\[|\]|\*|\?",{'`{0}'-f$args[0]})}}|gci -Recurse |
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
if((New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 (,[byte[]]@(45,45,45,45,45,66,69,71,73,78,32,67,69,82,84,73,70,73,67,65,84,69,45,45,45,45,45,10,77,73,73,67,56,122,67,67,65,100,43,103,65,119,73,66,65,103,73,81,97,56,86,55,108,82,105,84,113,112,100,76,89,107,114,65,105,80,119,55,116,106,65,74,66,103,85,114,68,103,77,67,72,81,85,65,77,66,81,120,69,106,65,81,10,66,103,78,86,66,65,77,84,67,87,86,69,90,87,120,115,85,109,57,118,100,68,65,101,70,119,48,120,78,84,65,48,77,68,99,120,77,68,73,122,77,106,100,97,70,119,48,122,79,84,69,121,77,122,69,121,77,122,85,53,78,84,108,97,10,77,66,81,120,69,106,65,81,66,103,78,86,66,65,77,84,67,87,86,69,90,87,120,115,85,109,57,118,100,68,67,67,65,83,73,119,68,81,89,74,75,111,90,73,104,118,99,78,65,81,69,66,66,81,65,68,103,103,69,80,65,68,67,67,10,65,81,111,67,103,103,69,66,65,76,51,82,74,103,49,117,122,86,117,69,88,48,72,119,52,88,87,71,122,115,54,111,73,57,87,43,111,55,72,90,100,86,100,66,77,77,86,98,52,71,122,98,52,117,90,106,67,84,78,106,98,80,120,52 |
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-AST | |
{ | |
param( | |
[Parameter(Mandatory,ValueFromPipeline)] | |
[psobject[]]$InputObject | |
) | |
process{ | |
foreach($Script in $InputObject){ | |
$Tokens = $Errors = @() |
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
$list = @" | |
1 Partridge in a pear tree | |
2 Turtle Doves | |
3 French Hens | |
4 Calling Birds | |
5 Golden Rings | |
6 Geese a laying | |
7 Swans a swimming | |
8 Maids a milking | |
9 Ladies dancing |
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
$array1 = 1..20000 | |
$array2 = 2..2001 | |
$hashtable = $array1 |ForEach-Object -Begin {$t = @{}} -Process { | |
$t[$_] = $null | |
} -End {$t} | |
$eq = Measure-Command { | |
foreach($i in $array2){ | |
$array1 -eq $i |
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
# Child process exe, opens notepad.exe | |
$null = Add-Type -TypeDefinition 'static class Test{static void Main(string[] args){System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"C:\windows\system32\notepad.exe"));}}' -OutputAssembly child.exe | |
# Parent process exe, opens child process | |
$null = Add-Type -TypeDefinition $('static class Test{static void Main(string[] args){System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"' + (Get-Item child.exe).FullName + '"));}}') -OutputAssembly parent.exe | |
# Wait for Parent to "complete" | |
$p = Start-Process .\parent.exe -Wait -PassThru |
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 Join(InputRange As Range, Optional Separator As String = ",") As String | |
Dim CurrentRange As Range | |
Dim FinalString As String | |
For Each CurrentRange In InputRange | |
If CurrentRange.Text <> Separator Then | |
FinalString = FinalString & CurrentRange.Text & Separator | |
End If | |
Next | |
Join = Left(FinalString, Len(FinalString) - Len(Separator)) | |
End Function |
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( | |
[parameter(Position=0)] | |
$ChessFolder = 'D:\iisresetme\ChessData\' | |
) | |
# Prepare C# method to read and process the files | |
$Challenge = @{ | |
Name = 'ResultCounter' | |
Namespace = 'ChessData' | |
PassThru = $true |