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
Install-WindowsFeature -Name Ad-Domain-Services -IncludeManagementTools | |
###local admin password.... | |
$pass = ConvertTo-SecureString "XXXXXXXXXX" -AsPlainText -Force | |
Install-ADDSForest -DomainName "MyNewDomain.local" -SafeModeAdministratorPassword $pass |
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
//The idea here is there's a difference between how the event repeats (Repetition) and when that repetition occurs (When/NotWhen). | |
// Between 9am and 6pm, run every 5 minutes, exactly on minute 0,5,10,etc., except on the last day of the month. | |
// Before 9am and after 6pm, run every 10 minutes, exactly on minute 0,10,20, etc, except on the last day of the month. | |
// On the last day of the month, run every 20 minutes, exactly on minute 0,20,40. | |
var config = ScheduleConfig.EveryMinute(5).OnTheMinute(0).When(Between(Hour(9),Hour(18))).WhenNot(DayOfMonth.Last).Named("DayTime") | |
.AddRepetition(Repetition.EveryMinute(10).OnTheMinute(0).When(Before(Hour(9)), After(Hour(18))).WhenNot(DayOfMonth.Last).Named("NightTime") | |
.AddRepetition(Repetition.EveryMinute(20).OnTheMinute(0).When(DayOfMonth.Last).Named("LastDayOfMonth"); | |
var schedule = new Schedule(scheduleConfig); //This could also be IObservable.... |
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
var http = require('http'); | |
var url = require("url"); | |
var path = require("path"); | |
var fs = require('fs'); | |
http.createServer(function(req, res) { | |
var uri = url.parse(req.url).pathname; | |
var filename = path.join(process.cwd(), uri); | |
if (fs.existsSync(filename)) { | |
var stats = fs.lstatSync(filename); |
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 System; | |
using System.Linq; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace SandboxThing | |
{ | |
class EncryptedString | |
{ | |
private const int AesBlockSize = 128; |
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
$adapter = Get-NetAdapter -Name "Ethernet" | |
$ipv4 = $adapter | Get-NetIPAddress -AddressFamily IPv4 | |
## Remove IPv6 Address and disable IPv6 binding.... | |
$ipv6 = $adapter | Get-NetIPAddress -AddressFamily IPv6 -ErrorAction SilentlyContinue | |
if ($ipv6) { | |
$ipv6 | Remove-NetIPAddress -Confirm:$false | |
} | |
$binding = (Get-NetAdapterBinding | Where-Object { $_.ComponentID -eq "ms_tcpip6" }) |
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 Clear-Memcache($server, $port = 11211) | |
{ | |
$msg = [System.Text.Encoding]::ASCII.GetBytes("flush_all`r`nquit`r`n") | |
$c = New-Object System.Net.Sockets.TcpClient($server, $port) | |
$str = $c.GetStream() | |
$str.Write($msg, 0, $msg.Length) | |
$buf = New-Object System.Byte[] 4096 | |
$count = $str.Read($buf, 0, 4096) | |
[System.Text.Encoding]::ASCII.GetString($buf, 0, $count) | |
$str.Close() |
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
//code from NServicebus.... | |
public static int WaitForReturn(this ICallback callback, TimeSpan timeout) | |
{ | |
int returnValue = 0; | |
ManualResetEvent handle = new ManualResetEvent(false); | |
callback.Register((Action<int>) (i => | |
{ | |
returnValue = i; | |
handle.Set(); | |
})); |
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-ChildItem C:\dir\* | %{ | |
$file1 = "C:\dir\$($_.Name)" | |
$file2 = "C:\dir\$($_.Name)" | |
. 'C:\Program Files\TortoiseGit\bin\TortoiseGitMerge.exe' -mine $file1 -base $file2 | |
#it takes a few seconds to open gitmerge. If you don't include this sleep your computer will implode. | |
Start-Sleep -Seconds 5 | |
} | |
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 Create-AspSessionDatabase ($dataSource, $database) { | |
. C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe -S $dataSource -d $database -ssadd -E -sstype c | |
} |
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 Copy-WUPowershellModule($computerName) { | |
$remotePath = "\\$($computerName)\c$\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate" | |
$localPath = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate" | |
if (! (Test-Path $remotePath )) { | |
Write-Host "Copying powershell module." | |
Copy-Item $localPath -Destination $remotePath -Recurse -Force | |
} | |
$command = { | |
##Add the Microsoft Update service | |
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false |