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 / variable-name-from-variable.ps1
Created August 27, 2015 04:26
variable name from variable in powershell
$n = "hello"
$p = "`$$($n) = `"goodbye`""
Invoke-Expression $p
@lantrix
lantrix / dsc-test-environment-AWS.ps1
Last active September 24, 2015 08:50
Create an empty Windows Server in existing AWS VPC/Subnet - for Sample environment http://www.systemcentercentral.com/day-1-intro-to-powershell-dsc-and-configuring-your-first-pull-server/
#PEM Key for password decrypt
$PEM = "$HOME\MyKey.pem"
$KeyName = "MyKey"
#EC2 Bootstrap
$EC2UserData = Get-Content "$HOME\ec2-user-data.ps1"
#Userdata has to be base64 encoded
$EC2UserDataBase64Encoded = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($EC2UserData))
[
{
"keys": ["ctrl+alt+f"],
"args": {
"id": "repl_f#",
"file": "config/F/Main.sublime-menu"
},
"command": "run_existing_window_command"
},
{
@lantrix
lantrix / packer windows compile.md
Last active December 22, 2016 04:46
Cross compile packer for Windows from Mac or Linux

Packer Cross Compile Windows binaries

Setup GO

  • Setup Golang.
  • Install gox for cross platform compilation:
    • go get -u github.com/mitchellh/gox

Compile Packer

{
"clusterName": "MyCluster",
"datacenterName": "Melbourne",
"hostName": "esxihost.localnet",
"ESXusernameText": "root",
"ESXpasswordText": "password",
"user": "packer",
"password": "password",
"vm_nameText": "PackerTemplateWin2012R2",
"vm_networkName": "VM Network",
{
"variables": {
"clusterName": "",
"datacenterName": "",
"hostName": "",
"ESXusernameText": "",
"ESXpasswordText": "",
"user": "",
"password": "",
"vm_nameText": "",
#Configure NIC as Env has no DHCP
$netadapter = Get-NetAdapter -Name Ethernet
## Disable DHCP
$netadapter | Set-NetIPInterface -DHCP Disabled
## Configure the IP address and default gateway for "VM Network" in Env
$netadapter | New-NetIPAddress -AddressFamily IPv4 -IPAddress 10.1.0.250 -PrefixLength 24 -Type Unicast -DefaultGateway 10.1.0.254
## Configure the DNS servers
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses ("172.1.0.2","172.1.0.3”)
@lantrix
lantrix / bash-rename-bulk.sh
Created September 18, 2015 04:37
rename many files with different extensions in bash
for f in *_*; do echo mv "${f}" "${f//_/-}"; done
for f in *_*; do echo mv "${f}" "NewPrefix${f/OldPrefix/}"; done
@lantrix
lantrix / PackerBaseWin2012R2-VMWare.json
Last active September 18, 2015 05:42
packer/issues#2676 config
{
"variables": {
"vcenter": "",
"clusterName": "",
"datacenterName": "",
"hostName": "",
"ESXusernameText": "",
"ESXpasswordText": "",
"user": "",
"password": "",