Skip to content

Instantly share code, notes, and snippets.

View lantrix's full-sized avatar
:octocat:
always coding and merging

Ted B lantrix

:octocat:
always coding and merging
View GitHub Profile
@lantrix
lantrix / ad-bits.ps1
Created March 8, 2016 01:15
powershell AD bits
Get-ADComputer -Filter * -SearchBase 'OU= SERVERS, DC=domain_name,DC=net' -Properties * | Where-Object {$_.serviceprincipalname -like '*exchange*'} |select-object name
@lantrix
lantrix / Set-Ec2AdminPasswordGeneration.ps1
Created March 16, 2016 03:33
PowerShell for pre AWS AMI creation to cause Administrator password to reset on next boot - used in Packer PowerShell Provisioner
$EC2SettingsFile='C:\Program Files\Amazon\Ec2ConfigService\Settings\Config.xml'
$xml = [xml](get-content $EC2SettingsFile)
$xmlElement = $xml.get_DocumentElement()
$xmlElementToModify = $xmlElement.Plugins
foreach ($element in $xmlElementToModify.Plugin) {
if ($element.name -eq 'Ec2SetPassword') {
$element.State='Enabled'
}
}
$xml.Save($EC2SettingsFile)
echo This task runs after the reboot task, as a buffer between the reboot script and the real reboot.
echo That is, THIS task will get all the INTERRUPTED errors, not the real scripts.
# Note: This script depends on the host machine's reboot process removing the 'rebooting=true' line from the buildAgent.properties
# See the plist in this gist, or add it to your rc.local.
echo Uptime:
uptime
echo Infinite loop until machine reboot, unless reboot is already complete:
@lantrix
lantrix / reboot-teamcity-agent.ps1
Last active May 12, 2016 06:16
PowerShell script build step to reboot a TeamCity agent after build is complete
$username = "%buildAgentAccessUser%"
$password = "%buildAgentAccessPassword%"
$authInfo = $username + ":" + $password
$authInfo = [System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($authInfo))
$uri = "%teamcity.serverUrl%/httpAuth/app/rest/agents/name:%teamcity.agent.name%/id"
#With thanks to Ivan Leonenko Blog https://ileonenko.wordpress.com/2012/09/21/start-teamcity-build-via-web-request-with-powershell-script/
$webRequest = [System.Net.WebRequest]::Create($uri)
$webRequest.Headers["Authorization"] = "Basic " + $authInfo
@lantrix
lantrix / Publish-AmiToCfn.ps1
Created May 13, 2016 05:24
PowerShell commandlet to update a cloudformation template with an AWS AMI provided from a build artifact of a TeamCity build
#requires -Version 4
<#
.SYNOPSIS
Will update a cloudformation template with an AWS AMI provided from a build artifact of a TeamCity build
.Description
When TeamCity has a build that runs packer, and spits out an AMI as an artifact,
this cmdlet can be used in a subsequent build - maybe triggered by the first build.
The cmdlet will then take the artifact from the fist build that spits out the AMI id and
update the cloudformation with the new AMI.
.EXAMPLE
@lantrix
lantrix / AdminDeployment.xml
Last active January 29, 2017 17:20
BoxStarter Windows 10
<?xml version="1.0" encoding="utf-8"?>
<AdminDeploymentCustomizations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/wix/2011/AdminDeployment">
<BundleCustomizations TargetDir="C:\Program Files (x86)\Microsoft Visual Studio 14.0" NoCacheOnlyMode="default" NoWeb="default" NoRefresh="default" SuppressRefreshPrompt="default" Feed="default" />
<SelectableItemCustomizations>
<SelectableItemCustomization Id="VSUV2RTMV2" Hidden="no" Selected="yes" FriendlyName="Visual Studio 2015 Update 2" />
<SelectableItemCustomization Id="MicroUpdateV2.2" Selected="yes" FriendlyName="Update for Microsoft Visual Studio 2015 (KB3151378)" />
<SelectableItemCustomization Id="WebToolsV1" Hidden="no" Selected="yes" FriendlyName="Microsoft Web Developer Tools" />
<SelectableItemCustomization Id="GitForWindowsx64V3" Hidden="no" Selected="yes" FriendlyName="Git for Windows" />
<SelectableItemCustomization Id="GitForWindowsx86V3"
# Your account access key - must have read access to your S3 Bucket
$accessKey = "YOUR-ACCESS-KEY"
# Your account secret access key
$secretKey = "YOUR-SECRET-KEY"
# The region associated with your bucket e.g. eu-west-1, us-east-1 etc. (see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-regions)
$region = "eu-west-1"
# The name of your S3 Bucket
$bucket = "my-test-bucket"
# The folder in your bucket to copy, including trailing slash. Leave blank to copy the entire bucket
$keyPrefix = "my-folder/"
@lantrix
lantrix / Join-Domain.ps1
Created June 8, 2016 06:02
Join domain with powershell - from http://stackoverflow.com/a/13492388
#get the credential
$cred = get-credential
$OU = "OU=Windows 10 Laptops,OU=Laptops,OU=MOE Workstations,DC=corp,DC=network"
# enter the computer in the right place
Add-Computer -DomainName EPFL -Credential $cred -OUPath $OU
# rename the computer with credential (because we are in the domain)
$Computer = Get-WmiObject Win32_ComputerSystem
$r = $Computer.Rename("NewComputerName", $cred.GetNetworkCredential().Password, $cred.Username)
@lantrix
lantrix / Makefile
Created June 14, 2016 09:41 — forked from wolfeidau/Makefile
Standard NodeJS make file.
REPORTER = spec
all: jshint test
test:
@NODE_ENV=test ./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --timeout 3000
jshint:
jshint lib examples test index.js
@lantrix
lantrix / NodeInstall.md
Last active June 15, 2016 03:37
Getting a new node project started with npm - NodeProject.md derived from https://www.wolfe.id.au/2014/02/01/getting-a-new-node-project-started-with-npm/

Install node:

brew install node
sudo npm install npm -g

Install node packages for dev:

npm install -g typings
npm install -g azure-cli
npm install -g jshint