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 Create-AesManagedObject($key, $IV) { | |
| $aesManaged = New-Object "System.Security.Cryptography.AesManaged" | |
| $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC | |
| $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros | |
| $aesManaged.BlockSize = 128 | |
| $aesManaged.KeySize = 256 | |
| if ($IV) { | |
| if ($IV.getType().Name -eq "String") { | |
| $aesManaged.IV = [System.Convert]::FromBase64String($IV) | |
| } |
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 Remove-Service { | |
| [cmdletbinding()] | |
| Param( | |
| [Parameter(Mandatory=$True,ValueFromPipeline=$True)] [object] $service | |
| ) | |
| BEGIN { } | |
| PROCESS { | |
| $serviceName = $service.Name | |
| if (-not $serviceName) { |
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
| Invoke-WebRequest https://chocolatey.org/install.ps1 -OutFile C:\Windows\Temp\chocoInstall.ps1 | |
| . C:\Windows\Temp\chocoInstall.ps1 | |
| $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") | |
| choco install -y 7zip | |
| choco install -y notepadplusplus | |
| choco install -y google-chrome-x64 | |
| ##choco install -y nodejs ##broken | |
| choco install -y visualstudiocode |
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
| var http = require('http'); | |
| var server = http.createServer(function (request, response) { | |
| response.writeHead(200, {"Content-Type": "text/plain"}); | |
| response.write("blah blah\n\n"); | |
| response.write(JSON.stringify(request.headers,null,' ')); | |
| response.write("\n\n" + request.method); | |
| response.write(request.url); | |
| response.end("\n\nHello World\n"); | |
| }); |
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
| //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 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
| 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 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 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 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 Send-MailgunEmail($from, $to, $subject, $body, $emaildomain, $apikey) { | |
| $idpass = "api:$($apikey)" | |
| $basicauth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($idpass)) | |
| $headers = @{ | |
| Authorization = "Basic $basicauth" | |
| } | |
| $url = "https://api.mailgun.net/v2/$($emaildomain)/messages" | |
| $body = @{ | |
| from = $from; |
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 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 |
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 Logout-AllUsers($computerName) { | |
| (gwmi win32_operatingsystem -ComputerName $computerName).Win32Shutdown(4) | |
| } |