Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Last active February 12, 2024 01:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellwest/fb14d9f3e29b3a3a06e50ad5a5252492 to your computer and use it in GitHub Desktop.
Save michaellwest/fb14d9f3e29b3a3a06e50ad5a5252492 to your computer and use it in GitHub Desktop.
Remove entries in the Sitecore Publishing Service queue using PowerShell.
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$query = @"
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_ActivationLock]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_Data_Params_FieldIds]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_Data_Params_Languages]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_JobManifest]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_JobMetadata]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_JobQueue]
DELETE TOP(100000) FROM [Sitecore.Masterx].[dbo].[Publishing_ManifestOperationResult]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_ManifestStatus]
DELETE TOP(100000) FROM [Sitecore.Masterx].[dbo].[Publishing_ManifestStep]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_PublisherOperation]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_TargetSyncState]
"@
Invoke-SqlCommand -Connection $connection -Query $query
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$query = @"
DELETE TOP (1000)
FROM [dbo].[Publishing_JobQueue]
SELECT COUNT(*) QueueCount
FROM [dbo].[Publishing_JobQueue]
"@
$records = Invoke-SqlCommand -Connection $connection -Query $query
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$query = @"
SELECT COUNT(*) AS QueueCount
--DELETE TOP (1000)
FROM [dbo].[Publishing_JobQueue]
WHERE CAST([Options] as nvarchar(max)) LIKE '%<a:Value>sitecore\Anonymous</a:Value>%'
"@
Invoke-SqlCommand -Connection $connection -Query $query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment