Skip to content

Instantly share code, notes, and snippets.

@toddb
Created August 3, 2011 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddb/1123853 to your computer and use it in GitHub Desktop.
Save toddb/1123853 to your computer and use it in GitHub Desktop.
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
}
Task Migrate -Description "Apply migrations to a specific version - default is latest" {
Migrate-Up $application $migrationsAssembly
}
Task Migrate-To -Description "Removes all migrations" {
Migrate-To $application $migrationsAssembly $to
}
#>
$provider = "SharePoint"
$log = ".\migrate.log"
function Migrate-To($application, $migrationsAssembly, $to){
Migrate-Setup
write-output "Migrating to application $application" > $log
write-output "Using dll $migrationsAssembly" >> $log
exec { .\lib\migratordotnet\Migrator.Console.exe $provider $application $migrationsAssembly -version $to >> $log }
get-content $log | write-host
}
function Migrate-Up($application, $migrationsAssembly){
Migrate-To $application $migrationsAssembly -1
}
function Migrate-Down($application, $migrationsAssembly){
Migrate-To $application $migrationsAssembly 0
}
function Migrate-Reset($application, $migrationsAssembly){
Migrate-Down $application $migrationsAssembly
Migrate-Up $application $migrationsAssembly
}
function Migrate-Setup() {
write-host "Ensuring that this is remote access to administration database introduced in SP2010"
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$contentService.RemoteAdministratorAccessDenied = $false
$contentService.Update()
}
function Migrate-Clobber($application){
Write-Host "You are very desparate if you are using Site-Version-Reset - good luck with you fixing!"
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$version = Get-SPWebApplication($application)
$version.Properties.Remove("version")
$version.Update()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment