sábado, 8 de fevereiro de 2014

SharePoint 2013 - Script para verificar se os limites do SharePoint foram atingidos

O script abaixo surgiu da mão da Margriet Bruggeman (SharePoint Dragons). O script verificará se um dos limites do SharePoint, descrito abaixo, foi atentido.

PowerShell Maxer for SharePoint 2013 is a script that checks for capacity planning limits as described per the Planning section of the TechNet Wiki SharePoint 2010 Best Practices overview page at http://social.technet.microsoft.com/wiki/contents/articles/12438.sharepoint-2013-best-practices.aspx

PowerShell Maxer for SharePoint 2013 can do the following things:


Checks user limit in groups.

Checks list item limits.
Checks site user limits.
Displays group membership.
Displays group owners.
Analyzes all web applications, site collections, and sites in a farm.
Displays which features have been activated at the farm, web application, site collection, and site level.
Checks sub site limits.
Checks site collection limits per content db.
Displays site collection owner and creation date.
Lists relevant application pool names.
Checks user limit in site collections. 

#region"SharePoint PowerShell Snapin"

$snapin="Microsoft.SharePoint.PowerShell"
if (get-pssnapin $snapin -ea "silentlycontinue")
{
Remove-PSSnapin $snapin
}
if (get-pssnapin $snapin -registered -ea "silentlycontinue")
{
Add-PSSnapin $snapin
}

#endregion

#region"Load PowerShell Configuration"

$0 = $myInvocation.MyCommand.Definition
$currentDir = [System.IO.Path]::GetDirectoryName($0)

#endregion

#region"PowerShell Function(s)"

function CountLists($currentWeb)
{
foreach ($currentList in $currentWeb.Lists)
{
$sw.WriteLine("There are {0} items in list {1}. A max of 30,000,000 is allowed.", $currentList.ItemCount, $currentList.Title)
}
}

function CountGroups($currentSc)
{
foreach($currentGroup in $currentSc.OpenWeb().SiteGroups)
{
$sw.WriteLine("Group {0} has {1} users. A max of 5,000 is allowed.", $currentGroup.Name, $currentGroup.Users.Count)
}
}

function CountUsers($currentSc)
{
foreach ($currentUser in $currentSc.OpenWeb().SiteUsers)
{
$sw.WriteLine("User {0} is a member of {1} groups. A max of 5,000 is allowed.", $currentUser.get_Name(), $currentUser.Groups.Count)
}
}

function CountOwners($ownersWeb)
{
foreach($ownersGroup in $ownersWeb.Groups)
{
if($ownersGroup.Name -like "*Owners*")
{
$sw.WriteLine("")
$sw.WriteLine("The following users are a member of the {0} group:", $ownersGroup.Name)
foreach($ownerUser in $ownersGroup.Users)
{
$sw.WriteLine("User: {0}", $ownerUser.Name)
}
}
}
}

function Countwebs($currentSc)
{
foreach ($currentWeb in $currentSc.AllWebs)
{
$sw.WriteLine("")
$sw.WriteLine("Analyzing Web site {0}", $currentWeb.Title)
CountOwners $currentWeb

$sw.WriteLine("")
$sw.WriteLine("The following features are active at Web scope:")
$contentWebAppServices = (Get-SPFarm).services
$webFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Web" }
if ($webFeatures -ne $null)
{
    foreach ($feature in $webFeatures)
    {
      if ((Get-SPFeature -Web $sc.Url | Where-Object {$_.Id -eq $feature.id}) -ne $null)
      {
          $sw.WriteLine("Feature: {0}, Typename {1} with GUID {2} is hidden {3}", $feature.DisplayName, $feature.TypeName, $feature.Id, $feature.Hidden)
      }
    }
}
$sw.WriteLine("")

$sw.WriteLine("Web site {0} has {1} sub sites. A max of 2,000 is allowed.", $currentWeb.Title, $currentWeb.Webs.Count)
CountLists $currentWeb
$sw.WriteLine("")
}
}

function CountContentDatabases($currentWebApp)
{
foreach($currentCd in $currentWebApp.ContentDatabases)
{
$sw.WriteLine("Content database {0} has {1} site collections. The maximum supported is 10,000. Recommended is a maximum of 5,000.", $currentCd.name, $currentCd.Sites.Count)
}
}

#endregion

Write-Host -f Green "Overview generated by the Maxer for SharePoint 2013"
Write-Host -f Green "Maxer was created by Nikander Bruggeman and Margriet Bruggeman of Lois & Clark IT Services"
Write-Host -f Green "Web site: http://www.loisandclark.eu"
Write-Host -f Green "Blog: http://www.sharepointdragons.com"

Write-Host -f Green "Start script"

$sw = New-Object -typename System.IO.StreamWriter($currentDir + "\Overviews.txt");
$sw.WriteLine($(Get-Date -format 'u'))
$sw.WriteLine("Overview generated by the Maxer for SharePoint 2013")
$sw.WriteLine("Maxer was created by Nikander Bruggeman and Margriet Bruggeman of Lois & Clark IT Services")
$sw.WriteLine("Web site: http://www.loisandclark.eu")
$sw.WriteLine("Blog: http://www.sharepointdragons.com")

$sw.WriteLine("")
$sw.WriteLine("The following features are active at Farm scope:")
$contentWebAppServices = (Get-SPFarm).services
$activeFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Farm" }
if ($activeFeatures -ne $null)
{
    foreach ($feature in $activeFeatures)
    {
      if ((Get-SPFeature -Farm | Where-Object {$_.Id -eq $feature.id}) -ne $null)
      {
        # Active feature
          $sw.WriteLine("Feature {0}, Typename {1} with GUID {2} is hidden {3}", $feature.DisplayName, $feature.TypeName, $feature.Id, $feature.Hidden)
      }
    }
}
$sw.WriteLine("")

foreach($webApp in $contentWebAppServices.WebApplications)
{
$sw.WriteLine("Web Application name: " + $webApp.name)
$sw.WriteLine("Application Pool name: " + $webApp.ApplicationPool.Name)
$sw.WriteLine("There are {0} content databases within web app {1}. The maximum allowed is 300.", $webApp.ContentDatabases.Count, $webApp.Name)
CountContentDatabases $webApp
$sw.WriteLine("")

$sw.WriteLine("The following features are active at WebApp scope:")
$contentWebAppServices = (Get-SPFarm).services
$webAppFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "WebApp" }
if ($webAppFeatures -ne $null)
{
    foreach ($feature in $webAppFeatures)
    {
      if ((Get-SPFeature -WebApp $webApp | Where-Object {$_.Id -eq $feature.id}) -ne $null)
      {
        $sw.WriteLine("Feature {0}, Typename {1} with GUID {2} is hidden {3}", $feature.DisplayName, $feature.TypeName, $feature.Id, $feature.Hidden)
      }
    }
}

$sw.WriteLine("")

foreach($sc in $webApp.Sites)
{
$sw.WriteLine("Analyzing site collection {0} created at {1}", $sc.Url, $sc.RootWeb.Created.ToShortDateString())
$sw.WriteLine("")

$sw.WriteLine("The following features are active at Site scope:")
$contentWebAppServices = (Get-SPFarm).services
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Site" }
if ($siteFeatures -ne $null)
{
    foreach ($feature in $siteFeatures)
    {
      if ((Get-SPFeature -Site $sc.Url | Where-Object {$_.Id -eq $feature.id}) -ne $null)
      {
          $sw.WriteLine("Feature {0}, Typename {1} with GUID {2} is hidden {3}", $feature.DisplayName, $feature.TypeName, $feature.Id, $feature.Hidden)
      }
    }
}
$sw.WriteLine("")

$sw.WriteLine("There are {0} users in site collection {1}. A max of 2,000,000 users is allowed.", $sc.OpenWeb().SiteUsers.Count, $sc.Url)
CountUsers $sc

$sw.WriteLine("")
$sw.WriteLine("There are {0} groups in site collection {1}. A max of 10,000 is allowed.", $sc.OpenWeb().SiteGroups.Count, $sc.Url)
CountGroups $sc

$sw.WriteLine("")
$sw.WriteLine("There are {0} sites in site collection {1}. A max of 250,000 is allowed.", $sc.AllWebs.Count, $sc.Url)
CountWebs $sc
}
$sw.WriteLine("There are {0} site collections within web app {1}. The maximum allowed is 750,000.", $webApp.Sites.Count, $webApp.Name)
$sw.WriteLine("")
}

$sw.Close();

Write-Host -f Green "Ready with the script"

Nenhum comentário:

Postar um comentário