Created
August 3, 2011 21:41
-
-
Save toddb/1123853 to your computer and use it in GitHub Desktop.
Migrations powershell functions for psake that wrap Migratordotnet SharePoint migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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