Created
December 16, 2019 12:13
-
-
Save jballe/7ff8163132571c187c42037de4c495ef to your computer and use it in GitHub Desktop.
Powershell scripts eg Sitecore
This file contains 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
$prefix = "customer-sitecorelogin-" | |
$packagePath = "R:\" | |
$packageFilter = "*Core.dacpac" | |
$dbowner = "Sitecore" | |
$sqlcmd = "C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\sqlcmd.exe" | |
$sqlpackage = "C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\sqlpackage.exe" | |
$ErrorActionPreference = "STOP" | |
$files = Get-ChildItem -Path $packagePath -Filter $packageFilter | |
$files | ForEach-Object { | |
$dacPath = $_.FullName | |
$dbName = ("{0}{1}" -f $prefix, $_.BaseName.Replace("Sitecore.", "sc_")) | |
Write-Host "Deploy $dacPath to $dbName" | |
& $sqlpackage /Action:Publish /SourceFile:$dacPath /TargetServerName:. /TargetDatabaseName:$dbName | |
& sqlcmd -d $dbName -Q "EXEC sp_changedbowner '${dbowner}'" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment