0

I would like to automate the DBCleanup tasks (/sitecore/admin/dbcleanup.aspx). The idea is to launch a TeamCity job that calls a powershell script to run the different cleanup jobs on the different databases. The only step missing is the powershell job to execute the CleanUp tasks ... Has anybody done this before or can you help me with a powershell script that does the trick?

1 Answer 1

1

I would first start with the SPE documentation as seen here. Once you have demonstrated locally that you can connect and remotely run tasks then check out the sample maintenance scripts under the System Maintenance module.

Module Tree

Example: Using the SPE Remoting module you can try something like this.

Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
        "master", "web" | Get-Database | 
            ForEach-Object { 
                [Sitecore.Globals]::LinkDatabase.Rebuild($_)
            }
} -AsJob
Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose
Stop-ScriptSession -Session $session

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.