I need to retreive how many sites are active in a web application using either powershell code or console application. Require the code ( also need how many users have accessed the active site collections if possible)?

  • What is active in your scenario? Jan 22, 2014 at 12:06
  • And is Site an SPSite or SPWeb? Jan 22, 2014 at 12:07
  • i need to find how many site collections are in active state based on last 10 users who logged in the site
    – priya
    Jan 22, 2014 at 12:10
  • @priya you should edit your question in order to make it clearer and include this precise requirement
    – MdMazzotti
    Jan 22, 2014 at 12:11
  • i need to find out how many site collections in a web application are in active state. By finding out how many users have accessed the individual sites recently (i.e also want to retreive last 10 users who logged in to the sites in the webapplication)
    – priya
    Jan 22, 2014 at 12:18

2 Answers 2


I don't know about active site collections, but to list all your site collections in a specific web application, run PowerShell as admin and type

  Get-SPWebApplication http://yourApp/ | Get-SPSite 

If you got a lot of site collections in a web application you can add the parameter -limit all to get-spsite.

About the last 10 users who visited the site collection, check your old post.

How to retreive last 10 users who have logged in a site using Power shell script?


You may need to define what you mean by Active. If it is simply viewing a site then it is difficult but if it is some edit been done in the site then you should try to use SPWeb.LastItemModifiedDate to get the date any item was modified in the site and based on the return date you can judge whether the site has been active or not.

Your Answer

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

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