Skip to content

Instantly share code, notes, and snippets.

<#
Basic tasks for SharePoint. These wrap many powershell commandlets which littles bits and pieces that actually work. They
are particularly designed for reuse with psake scripts. Belows is a sample psake script for deploying a sharepoint.
For building and package see: . .\scripts\build-tasks.ps1 # see gist: https://gist.github.com/1108813
$framework = '3.5x64'
. .\scripts\sharepoint-tasks.ps1
Properties {
@toddb
toddb / migrations-tasks.ps1
Created August 3, 2011 21:41
Migrations powershell functions for psake that wrap Migratordotnet SharePoint migrations
<#
Basic migration tasks for SharePoint.
$framework = '3.5x64'
. .\scripts\migrations-tasks.ps1
Properties {
$application = "http://mysites"
$migrationsAssembly = "$base_dir\lib\migratordotnet\Infrastructure.dll"
$to = -1
@toddb
toddb / test-tasks.ps1
Created August 9, 2011 06:30
Test tasks for Gallio in powershell with psake - helps with unit, integration and system tests
<#
Usage for Gallio tests:
Task Test-System -Description "Runs the system tests via Gallio" {
Test-Gallio $proj $configuration $platform $dll "system" "Test.System"
# Test-Gallio ".\src\Test.Unit\Test.Unit.csproj" Release x64 ".\src\Test.Unit\bin\Release\x64\Test.Unit.dll" "unit"
}
}
#>
@toddb
toddb / here.cmd
Created August 9, 2011 21:52
Here.cmd for powershell, psake and msbuild
@echo off
path = %path%;%WINDIR%\Microsoft.NET\Framework\v4.0.30319\
powershell -ExecutionPolicy Unrestricted -NoExit -Command " &{import-module .\scripts\psake.psm1; Invoke-Psake -docs}"
@toddb
toddb / Install.bat
Created August 9, 2011 21:53
Sample install.bat for psake with environment handin
@echo off
echo.
echo Running as:
whoami
echo.
set application=%1
if NOT '%application%'=='' GOTO :environmentcheck
@toddb
toddb / adminuser-setup-psake.ps1
Created August 10, 2011 20:21
Admin user setup in Sharepoint power psake
Properties {
$site_owner = "domain\serviceaccount"
$ca_port = 3456
}
Task AdminUser-Setup -Depends Solution-Setup -Description "Sets the current user as a farm admin on current computer" {
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$whoami = [Security.Principal.WindowsIdentity]::GetCurrent().Name
Write-Host "You are logged in as $whoami"
@toddb
toddb / db-setup.psake.ps1
Created August 10, 2011 20:24
Use sql script for sharepoint in psake
Task Db-Setup -Description "Adds the current user for access to SharePoint schemas - DEV only" {
$userToAdd = Read-Host -Prompt 'User to add to Farm Admin group <DOMAIN>\<USERNAME>'
$db_env = Read-Host -Prompt 'Environment suffix of the database to setup'
Write-Host "If this script has a problem then you don't have login access - please sort this out first"
Write-Host "see http://www.sharepointassist.com/2010/01/29/the-local-farm-is-not-accessible-cmdlets-with-featuredependencyid-are-not-registered/"
$whoami = [Environment]::UserName
Write-Host "Adding dev user to database: $whoami"
Write-Host "Enter the password for the user $site_owner"
exec { sqlcmd -i .\dev-powershell-access.sql -U $whoami -v user=$userToAdd -v db_env=$db_env }
@toddb
toddb / update-host.psake.ps1
Created August 10, 2011 20:30
Update host file in psake
Property {
$domain = ""
}
Task Hostfile-Update -Description "Add new sites to the host file" {
$host_file = "$env:windir\System32\drivers\etc\hosts"
if ((Get-Content $host_file | ForEach-Object{$_ -eq "127.0.0.1 $domain "}) -notcontains "True")
{
Add-Content $host_file "`n127.0.0.1 $domain "
}
@toddb
toddb / gist:1474205
Created December 13, 2011 22:27 — forked from mathieul/gist:966776
Require files using RequireJS before running Jasmine specs
/**
* @license Copyright (c) 2012, toddb GoneOpen Limited.
* Available via the MIT or new BSD license.
* based on https://gist.github.com/966776 (mathieul) and forked to https://gist.github.com/1474205
* jasmine.requirejs() returns a function that will load the file(s) required
* and will wait until it's done before proceeding with running specs.
* The function returned is intended to be passed to beforeEach() so the file(s)
* is(are) loaded before running each spec.
*
@toddb
toddb / teamcity.pp
Created March 20, 2012 21:52
Puppet Teamcity script - straightforward, non-modularised & procedural
class teamcity {
@package{ [ "java-1.6.0-openjdk", "wget", "tar", "gzip" ]:
ensure => installed,
}
$src="http://download.jetbrains.com/teamcity/TeamCity-7.0.tar.gz"
$username="teamcity"
$installdir="/opt"