Tuesday, July 12, 2011

using Microsoft.Web.Administration;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Web.Administration;

namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            ServerManager manager = new ServerManager();
            foreach (var r in manager.Sites)
            {
                Console.WriteLine(r.Name);
            }
            Console.WriteLine("--------------------------------------");
            Console.WriteLine("Dispaly all the site which is started");
            ServerManager manager1 = new ServerManager();
            var result = from r in manager1.Sites
                         where r.State == ObjectState.Started
                         select r;
            foreach (var r1 in result)
            {
                Console.WriteLine(r1.Name);
            }
            Console.WriteLine("--------------------------------------");
            Console.WriteLine("Dispaly application running in perticular application pool");
            ServerManager manager2 = new ServerManager();
            var result2 = from r in manager2.Sites
                          from k in r.Applications
                          where k.ApplicationPoolName.Equals("SharePoint - 80", StringComparison.InvariantCultureIgnoreCase)
                          select r;
            foreach (var r2 in result2)
            {
                Console.WriteLine(r2.Name);
            }
            Console.ReadKey(true);
        }
    }
}

my sincere thanks to www.debugmode.net

No comments:

Post a Comment