Sharepoint Timer Job

Hello,

Using Visual Studio 2005 and c#. Program to Build a sample timer job which reads site collection sizes for all site collections in a given web application in MOSS 2007


Thanks in advance

ranimadinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

quihongCommented:
VS 2005 (and even VS 2010) don't have project templates for SharePoint Timer Job.

Personally, I think its so much simpler to write a console app or a Powershell Script and schedule it via the Task Scheduler.
quihongCommented:
BTW, the stsadm -o enumsites command will list out the size of the site collection for a given web app. The output is XML so its would be easy to consume the data and do what you need like populating a SP List.
ranimadinAuthor Commented:
could you elaborate your answers or please provide sites for references.


thank you
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

quihongCommented:
Not sure which part you want me to elaborate on...

What do you want to do with the site collection size data?
ranimadinAuthor Commented:
quihongCommented:
My opinion is that its much simpler to use the built in Task Scheduler versus the SharePoint Timer service. Especially for something like, "I want to know the size of all my site collections".

What do you want to do with the site collection size data?
ranimadinAuthor Commented:
site collection size data for montiorning and keepng track. I want to understand the code logic and programmatically how it works.
quihongCommented:
Sorry for the confusion, what do you want to do with the site collection size data? Output to a file? Write to a database? Write to a SP list?
ranimadinAuthor Commented:
write to a SP list
quihongCommented:
Below is a PowerShell Script that list all the Site Collection size for a given Web App.

Here is a good tutorial on how to write the data to a SharePoint List.
http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?ID=10

The idea would be that you would schedule this powershell script via the built in Windows Task Scheduler versus utilizing the SharePoint Timer Service.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

$WebAppURL =  "http://portal"
$Thesite = New-Object Microsoft.SharePoint.SPSite($WebAppURL)
$webApp = $Thesite.WebApplication
write-host "Total of Site Collections: ", $webApp.Sites.Count

$allSiteCollections = $webApp.Sites

foreach ($site in $allSiteCollections)
{
    $usageInfo = $site.Usage
    $storageUsed = $usageInfo.Storage

    Write-Host "Site Collection URL: ", $site.Url
    $totalbytes = $storageUsed
    $totalMB = $storageUsed/1024/1024
    Write-Host "    Storage: ", $totalMB, "MB"
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.