Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created September 12, 2015 17:09
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 michaellwest/dcd52a4ecf7bca0df7c5 to your computer and use it in GitHub Desktop.
Save michaellwest/dcd52a4ecf7bca0df7c5 to your computer and use it in GitHub Desktop.
Adapted the functions written by Nick Wesselman to work directly in SPE.
<#
.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