-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunTimerJob.ps1
More file actions
36 lines (25 loc) · 1.77 KB
/
RunTimerJob.ps1
File metadata and controls
36 lines (25 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<#
This Sample Code is provided for the purpose of illustration only and is not intended to be used in a production environment.
THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
We grant you a nonexclusive, royalty-free right to use and modify the sample code and to reproduce and distribute the object
code form of the Sample Code, provided that you agree:
(i) to not use our name, logo, or trademarks to market your software product in which the sample code is embedded;
(ii) to include a valid copyright notice on your software product in which the sample code is embedded; and
(iii) to indemnify, hold harmless, and defend us and our suppliers from and against any claims or lawsuits, including
attorneys' fees, that arise or result from the use or distribution of the sample code.
Please note: None of the conditions outlined in the disclaimer above will supercede the terms and conditions contained within
the Premier Customer Services Description.
#>
Add-PSSnapin microsoft.sharepoint.powershell
$WebAppUrl = "http://contoso.com"
$WebApp = get-spwebapplication $WebAppUrl
$ContentDBs = $WebApp.ContentDatabases
$timerJobDef = Get-SPTimerJob | where {$_.Title -like "content organizer*" -and $_.WebApplication.Url -eq $WebApp.Url}
foreach ($db in $ContentDBs)
{
write-host $db.Name, $db.Id
$constructor = [Microsoft.SharePoint.Administration.SPJobState].GetConstructors([Reflection.BindingFlags] "NonPublic,Instance")
$jobState = $constructor.Invoke([Object[]] @($timerJobDef.Id, $db.Id))
$timerJobDef.Execute($db, $jobState)
}