Skip to content

Instantly share code, notes, and snippets.

View grenade's full-sized avatar

rob thijssen grenade

View GitHub Profile
Param(
[string] $source,
[string] $target,
[string] $fat_args = "/FFT /Z /XA:H /W:5"
[switch] $mirror
)
if ($mirror) {
Invoke-Expression ("robocopy {0} {1} /MIR {2}" -f $source, $target, $fat_args)
}
else {
# $HOME/.gitconfig
[user]
name = Rob Thijssen
email = [email protected]
[core]
autocrlf = true
[http]
proxy = http://127.0.0.1:3128
[https]
proxy = http://127.0.0.1:3128
@grenade
grenade / Add-LocalGroupDomainUser.ps1
Last active December 31, 2015 02:59
Add a domain user to a local group
function Add-LocalGroupDomainUser {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $computer,
[Parameter(Mandatory = $true)]
[string] $group,
[Parameter(Mandatory = $true)]
param(
[string] $username = $env:username
)
function Get-User {
param(
[System.String] $username
)
$ds = New-Object System.DirectoryServices.DirectorySearcher
$ds.Filter = "(&(objectCategory=person)(sAMAccountName=$username))"
$ds.SearchRoot = "LDAP://{0}" -f ([ADSI] "LDAP://RootDSE").Get("rootDomainNamingContext")
@grenade
grenade / applicationHost.config
Created December 17, 2013 14:04
All of the IIS configuration required to host TeamCity, Stash and NuGetGallery on a single IIS server using IIS web farm and rewrite rules to route hostnames:80 to TomCat sites on their default ports. The file normally lives at: c:\windows\system32\inetsrv\config\applicationhost.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--
...
-->
<system.applicationHost>
<applicationPools>
<add name="DefaultAppPool" />
<add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
<add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
@grenade
grenade / teamcity-backup.ps1
Created December 17, 2013 16:38
Get TeamCity to back itself up by creating a scheduled build configuration that runs this Powershell script.
param(
[string] $username,
[string] $password,
[string] $baseUrl = "http://teamcity:8111",
[int] $sleep = 10,
[int] $timeout = 600
)
function Execute-TeamCityBackup {
param(
[string] $baseUrl,
@grenade
grenade / ExtractFileFromZip.ps1
Last active December 31, 2015 22:29
Extract a single file from a zip file
param(
[string] $archive,
[string] $savePath,
[string] $filename = [System.IO.Path]::GetFileName($savePath)
)
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
$outStream = New-Object System.IO.FileStream ("$savePath"), 'Create'
$inStream = ([System.IO.Compression.ZipFile]::OpenRead($archive).Entries | Where { $_.Name -eq $filename }).Open()
$inStream.CopyTo($outStream)
$inStream.Close()
@grenade
grenade / create-website.ps1
Last active December 31, 2015 22:59
create-website.ps1: Create (or delete) a new remote website under IIS with associated application pool and properties.deploy-website.ps1: WebDeploy (MSDeploy) a zip package file to a remote website.
<#
.Synopsis
Create website under IIS on a remote host.
.Description
Create a website and its Application Pool. Set properties of both.
.Parameter site
Defines the display name (in IIS Manager) of the website.
Mandatory parameter
.Parameter port
Defines the listening port for the website.
@grenade
grenade / teamcity-backup.ps1
Last active January 2, 2016 12:19
TeamCity maintenance tasks including (and only) triggering regular backups.
<#
.Synopsis
Trigger a TeamCity backup using the TeamCity REST API.
.Parameter username
Defines a TeamCity username which has authority to trigger backups.
.Parameter password
Defines the password for the user which will trigger the backup.
.Parameter baseUrl
Defines the URL to the TeamCity server (eg: http://teamcity.example.com).
If not set, the script will attempt to determine it from the TeamCity properties file.
$webClient = New-Object System.Net.WebClient
$webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Invoke-Expression ($webClient.DownloadString('https://chocolatey.org/install.ps1'))