Skip to content

Instantly share code, notes, and snippets.

Avatar

Alastair Crabtree alastairtree

View GitHub Profile
View SetupServer
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
cinst GoogleChrome
cinst PowerShell4
cinst webpi
cinst notepadplusplus
View gist:fa2c08c5d6e79bc6e1ed
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
choco install cccp
choco install vlc
choco install powershell4
View SetupControllerPC
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
cinst dotnet4.5.1
cinst firefox
cinst 7zip
cinst putty
@alastairtree
alastairtree / restart.ps1
Created Aug 6, 2015
Restart a remote machine using powershell
View restart.ps1
# at an PS> prompt with sufficient admin credentials
Restart-Computer ServerName -force
# or
# Restart-Computer "ServerName1", "ServerName2" -force
# More info https://mcpmag.com/articles/2012/04/10/how-to-restart-computers-remotely-via-powershell.aspx
View DeleteWindowsService.ps1
Function KillTheService($ServiceName)
{
$service = Get-Service $ServiceName -ErrorAction SilentlyContinue
if (!$service)
{
"Could not find service $ServiceName"
}
else
{
View Octopus.WindowsService.BeforePostDeploy.ps1
## --------------------------------------------------------------------------------------
## Configuration
## --------------------------------------------------------------------------------------
$isEnabled = $OctopusParameters["Octopus.Action.WindowsService.CreateOrUpdateService"]
if (!$isEnabled -or ![Bool]::Parse($isEnabled))
{
exit 0
}
@alastairtree
alastairtree / create-and-share.bat
Created Dec 14, 2015
cmd.exe/psexec.exe oneliner to create a folder and share it
View create-and-share.bat
REM Will create c:\Deploy, share as "\\server\Deploy"
REM and grant change permissions to administrators and users
cmd /c "(C: & (mkdir C:\Deploy 2> NUL)) & (net share Deploy=C:\Deploy /grant:"Users",CHANGE /grant:Administrators,CHANGE 2> NUL)"
@alastairtree
alastairtree / ExcelExportTool.cs
Created Dec 7, 2015
Export items to an excel spreadsheet
View ExcelExportTool.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using OfficeOpenXml;
using OfficeOpenXml.Table;
namespace Utils
{
public static class ExcelExportTool
@alastairtree
alastairtree / System Design.md
Created Apr 18, 2016 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

#System Design Interview Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
View RunProcessAsAnotherUserAndCaptureOutput.ps1
$DemoUser = 'Domain\username'
$DemoPass = 'complexpassword'
$Command = "ECHO 'Hello world'; WhoAmi;"
$StdOutLogFile = "$env:windir\temp\PowerShellElevatedStdOut.log"
$SecurePassword = ConvertTo-SecureString $DemoPass -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential $DemoUser, $securePassword
"Running '$Command' as current user"