Created
September 12, 2015 17:09
-
-
Save michaellwest/dcd52a4ecf7bca0df7c5 to your computer and use it in GitHub Desktop.
Adapted the functions written by Nick Wesselman to work directly in SPE.
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
<# | |
.NOTES | |
Copied from Nick Wesselman's video https://www.youtube.com/watch?v=tXTbMRVF0ts | |
#> | |
function Start-Publish { | |
param( | |
[string]$Source = "master", | |
[string]$Target = "web" | |
) | |
$sourceDb = [Sitecore.Data.Database]::GetDatabase($Source) | |
$targetDb = [Sitecore.Data.Database]::GetDatabase($Target) | |
$languages = [Sitecore.Globalization.Language]::GetLanguages($sourceDb) | |
$handle = [Sitecore.Publishing.PublishManager]::PublishSmart($sourceDb, @($targetDb), $languages) | |
$handle.ToString() | |
} | |
function Check-PublishStatus { | |
param( | |
[string]$HandleName | |
) | |
$handle = [Sitecore.Handle]::Parse($HandleName) | |
[Sitecore.Publishing.PublishManager]::GetStatus($handle) | |
} | |
$handle = Start-Publish | |
$status = Check-PublishStatus -HandleName $handle | |
$processed = -1 | |
while(-not $status.IsDone) { | |
if($status.Processed -ne $processed) { | |
$processed = $status.Processed | |
Write-Host "Publishing: $($processed) items" | |
} | |
Start-Sleep -Seconds 1 | |
$status = Check-PublishStatus -HandleName $handle | |
} | |
Write-Host "Publishing: done" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment