Wednesday, February 18, 2015

Powershell : Get count of site collections in Webapplication



param($Site,$FilePath)
   
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
   
function GenerateAllSitecollectionsCountInWebapplication ($url)
{
    write-host "Extracting the count of site collections in web application....." -foregroundcolor black
    try
      {
         $Site=Get-SPSite $url        
         $spWebApp = $Site.WebApplication
         write-host Total count in $url is   $Site.WebApplication.Sites.Count -foregroundcolor red
      }
   catch
      {
          write-host "Unable to Extract Sitecollection count .."  -foregroundcolor red
          break
      }
GenerateAllSitecollectionsCountInWebapplication -Url "www.yoursite.com"


No comments:

Post a Comment