Document your Farm with SharePoint Lists using PowerShell

If you are the sole Administrator of a SharePoint Farm, you will know your farm like the back of your hand but once it grows and becomes mission critical, it will be necessary for Team Administration resulting in an exponential growth of communication channels leading to errors. The Farm Administrator needs to know every detail including every configuration setting that could affect the Farm and when the Admin team grows, how do you continue to maintain control so you can collectively Administer and support the Farm? Communication and documentation how to win this battle.

Documenting a moving target is difficult, things are changing every day, features are added, content databases grow, quotas change etc. The first step is to baseline your configuration so you can compare settings to the previous months or years so when something goes wrong, you can compare and find out exactly what and when it changed. It is imperative to set up a process for documenting your Farm and will especially come in handy when troubleshooting problems. Implementing a manual process is doomed to failure. PowerShell and SharePoint lists to the rescue.

Why not create a SharePoint Site and store all your settings in various lists. You can use all of SharePoint goodness to filter, sort, search and compare. You have one place to go to check your settings and to find what you are looking for efficiently because this is what SharePoint is good at. But you do not have time to create lists and populate them with current data. The PowerShell script below is the first in a series of scripts I made that automates the entire process. I start with capturing the main Farm level objects and properties and will later capture Web Apps, Service Apps, Features, site collections until every property of every object is in a list for quick access to the Administrator or the Troubleshooter.

PowerShell Script – Create SharePoint List and dump farm level properties into the list

# First Create a list for storing Property values, For testing purposes, if the list exists we will delete it.

    $spWeb = Get-SPWeb http://sp.sp.local/Admin -AssignmentCollection $SPAssignment    #Get SPWeb Instance
    if($SPweb.Lists["FarmLevelProperties"]) {$SPweb.Lists["FarmLevelProperties"].Delete();}
    $spTemplate = $spWeb.ListTemplates["Custom List"]     #Create SPTemplate instance of Type Custom List
    $spWeb.Lists.Add("FarmLevelProperties", "Store Farm Level properties from PS Script", $spTemplate)     #Add list to site
    $SPlist = $SPweb.Lists["FarmLevelProperties"]   

    #Lets add our fields to the new list, one field per property

        $SPlist.Fields.Add("BuildVersion", "Text", 0)
        $SPlist.Fields.Add("Status", "Text", 0)
        $SPlist.Fields.Add("DaysBeforePasswordExpirationToSendEmail", "Text", 0)
        $SPlist.Fields.Add("DefaultServiceAccount", "Text", 0)
        $SPlist.Fields.Add("Servers", "Text", 0)
        $SPlist.Fields.Add("NeedsUpgrade", "Text", 0)
        $SPlist.Fields.Add("NeedsUpgradeIncludeChildren", "Text", 0)
        $SPlist.Fields.Add("TimerService", "Text", 0)
        $SPlist.Fields.Add("TypeName", "Text", 0)
        $SPlist.Fields.Add("Parent", "Text", 0)
        $SPlist.Fields.Add("ErrorReportingEnabled", "Text", 0)
        $SPlist.Fields.Add("ErrorReportingAutomaticUpload", "Text", 0)
        $SPlist.Fields.Add("DownloadErrorReportingUpdates", "Text", 0)
        $SPlist.Fields.Add("PasswordChangeEmailAddress", "Text", 0)
        $SPlist.Fields.Add("PasswordChangeGuardTime", "Text", 0)
        $SPlist.Fields.Add("PasswordChangeMaximumTries", "Text", 0)
        $SPlist.Fields.Add("IsPaired", "Text", 0)
        $SPlist.Fields.Add("PairConnectionString", "Text", 0)
        $SPlist.Fields.Add("ServiceApplicationProxyGroups", "Text", 0)
        $SPlist.Fields.Add("ServiceProxies", "Text", 0)
        $SPlist.Fields.Add("SiteSubscriptions", "Text", 0)
        $SPlist.Fields.Add("Properties", "Text", 0)
        $SPlist.Fields.Add("CanSelectForBackup", "Text", 0)
        $SPlist.Fields.Add("DiskSizeRequired", "Text", 0)
        $SPlist.Fields.Add("CanRenameOnRestore", "Text", 0)
        $SPlist.Fields.Add("CanBackupRestoreAsConfiguration", "Text", 0)
        $SPlist.Fields.Add("TraceSessionGuid", "Text", 0)
        $SPlist.Fields.Add("Services", "Text", 0)

    #Create View and set some key fields and make it the default view
        $spViewQuery = “<OrderBy><FieldRef Name=”"Modified”" Ascending=”"False”" /></OrderBy>”
        $spViewFields = New-Object System.Collections.Specialized.StringCollection    #Create string collection object
        $spViewFields.Add("Title")
        $spViewFields.Add("BuildVersion")
        $spViewFields.Add("Status")
        $spViewFields.Add("NeedsUpgrade")
        $spViewFields.Add("DiskSizeRequired")
        $spViewFields.Add("Servers")
        $spViewFields.Add("TypeName")
        $spViewName = "Properties"        #Set view name
        $spListView = $spList.Views.Add($spViewName, $spViewFields, $spViewQuery, 100, $True, $False, “HTML”, $False)    #Add view to list
        $spListView.DefaultView = $True       #Set view as default
        $spListView.Update()    #Update view to reflect changes in site

$spFarm = Get-SPFarm
# Update the new list with property values from the SPFarm Object
    foreach ($row in $SPFarm)
    {
         $item = $SPlist.Items.Add();
         $item["DiskSizeRequired"] = $Row.DiskSizeRequired
         $item["CanRenameOnRestore"] = $Row.CanRenameOnRestore
         $item["CanBackupRestoreAsConfiguration"] = $Row.CanBackupRestoreAsConfiguration
         $item["TraceSessionGuid"] = $Row.TraceSessionGuid
         $item["Services"] = $Row.Services
         $item["DownloadErrorReportingUpdates"] = $Row.DownloadErrorReportingUpdates
         $item["PasswordChangeEmailAddress"] = $Row.PasswordChangeEmailAddress
         $item["PasswordChangeGuardTime"] = $Row.PasswordChangeGuardTime
         $item["DaysBeforePasswordExpirationToSendEmail"] = $Row.DaysBeforePasswordExpirationToSendEmail
         $item["PasswordChangeMaximumTries"] = $Row.PasswordChangeMaximumTries
         $item["IsPaired"] = $Row.IsPaired
         $item["PairConnectionString"] = $Row.PairConnectionString
         $item["ServiceApplicationProxyGroups"] = $Row.ServiceApplicationProxyGroups
         $item["ServiceProxies"] = $Row.ServiceProxies
         $item["SiteSubscriptions"] = $Row.SiteSubscriptions
         $item["Properties"] = $Row.Properties
         $item["CanSelectForBackup"] = $Row.CanSelectForBackup
         $item["Title"] = $Row.Name
         $item["BuildVersion"] = $Row.BuildVersion
         $item["Status"] = $Row.Status
         $item["DaysBeforePasswordExpirationToSendEmail"] = $Row.DaysBeforePasswordExpirationToSendEmail
         $item["DefaultServiceAccount"] = $Row.DefaultServiceAccount.Name
         $item["Servers"] = $Row.Servers
         $item["NeedsUpgrade"] = $Row.NeedsUpgrade
         $item["NeedsUpgradeIncludeChildren"] = $Row.NeedsUpgradeIncludeChildren
         $item["TimerService"] = $Row.TimerService
         $item["TypeName"] = $Row.TypeName
         $item["Parent"] = $Row.Parent
         $item["ErrorReportingEnabled"] = $Row.ErrorReportingEnabled
         $item.Update()
    $spTemplate.Dispose
    $SPlist.Dispose 
    $item.Dispose
    $spWeb.dispose

Write-Host -ForegroundColor red `n `n "Go see your new list at $spWeb"

}

 

Here is a Reference list of Farm level Properties

AlternateUrlCollections                 Property   Microsoft.SharePoint.Administration.SPAlternateUrlColle…
BuildVersion                            Property   System.Version BuildVersion {get;}                       
CanBackupRestoreAsConfiguration         Property   System.Boolean CanBackupRestoreAsConfiguration {get;}    
CanMigrate                              Property   System.Boolean CanMigrate {get;}                         
CanRenameOnRestore                      Property   System.Boolean CanRenameOnRestore {get;}                 
CanSelectForBackup                      Property   System.Boolean CanSelectForBackup {get;set;}             
CanSelectForRestore                     Property   System.Boolean CanSelectForRestore {get;set;}            
CanUpgrade                              Property   System.Boolean CanUpgrade {get;}                         
CEIPEnabled                             Property   System.Boolean CEIPEnabled {get;set;}                    
DaysBeforePasswordExpirationToSendEmail Property   System.Int32 DaysBeforePasswordExpirationToSendEmail {g…
DefaultServiceAccount                   Property   Microsoft.SharePoint.Administration.SPProcessAccount De…
DiagnosticsProviders                    Property   Microsoft.SharePoint.Diagnostics.SPDiagnosticsProviderC…
DiskSizeRequired                        Property   System.UInt64 DiskSizeRequired {get;}                    
DisplayName                             Property   System.String DisplayName {get;}                         
DownloadErrorReportingUpdates           Property   System.Boolean DownloadErrorReportingUpdates {get;set;}  
ErrorReportingAutomaticUpload           Property   System.Boolean ErrorReportingAutomaticUpload {get;set;}  
ErrorReportingEnabled                   Property   System.Boolean ErrorReportingEnabled {get;set;}          
ExternalBinaryStoreClassId              Property   System.Guid ExternalBinaryStoreClassId {get;set;}        
Farm                                    Property   Microsoft.SharePoint.Administration.SPFarm Farm {get;}   
FeatureDefinitions                      Property   Microsoft.SharePoint.Administration.SPFeatureDefinition…
Id                                      Property   System.Guid Id {get;set;}                                
IsBackwardsCompatible                   Property   Microsoft.SharePoint.TriState IsBackwardsCompatible {ge…
IsPaired                                Property   System.Boolean IsPaired {get;set;}                       
Name                                    Property   System.String Name {get;set;}                            
NeedsUpgrade                            Property   System.Boolean NeedsUpgrade {get;set;}                   
NeedsUpgradeIncludeChildren             Property   System.Boolean NeedsUpgradeIncludeChildren {get;}        
PairConnectionString                    Property   System.String PairConnectionString {get;set;}            
Parent                                  Property   Microsoft.SharePoint.Administration.SPPersistedObject P…
PasswordChangeEmailAddress              Property   System.String PasswordChangeEmailAddress {get;set;}      
PasswordChangeGuardTime                 Property   System.Int32 PasswordChangeGuardTime {get;set;}          
PasswordChangeMaximumTries              Property   System.Int32 PasswordChangeMaximumTries {get;set;}       
PersistedFileChunkSize                  Property   System.Int32 PersistedFileChunkSize {get;set;}           
Products                                Property   System.Collections.Generic.IEnumerable`1[[System.Guid, …
Properties                              Property   System.Collections.Hashtable Properties {get;}           
Servers                                 Property   Microsoft.SharePoint.Administration.SPServerCollection …
ServiceApplicationProxyGroups           Property   Microsoft.SharePoint.Administration.SPServiceApplicatio…
ServiceProxies                          Property   Microsoft.SharePoint.Administration.SPServiceProxyColle…
Services                                Property   Microsoft.SharePoint.Administration.SPServiceCollection…
SiteSubscriptions                       Property   Microsoft.SharePoint.SPSiteSubscriptionCollection SiteS…
Solutions                               Property   Microsoft.SharePoint.Administration.SPSolutionCollectio…
Status                                  Property   Microsoft.SharePoint.Administration.SPObjectStatus Stat…
TimerService                            Property   Microsoft.SharePoint.Administration.SPTimerService Time…
TraceSessionGuid                        Property   System.Guid TraceSessionGuid {get;}                      
TypeName                                Property   System.String TypeName {get;}                            
UpgradeContext                          Property   Microsoft.SharePoint.Upgrade.SPUpgradeContext UpgradeCo…
UpgradedPersistedProperties             Property   System.Collections.Hashtable UpgradedPersistedPropertie…
Version                                 Property   System.Int64 Version {get;}