SharePoint farm config - via powershell
"Can't I just use Powershell to dump this info? - So let's see!"
# run this from a front-end as Farm Administrator
# tell powershell to load Sharepoint DLL's
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Administration.ServerFarm")
#
# find the installed iFilters
#
function Get-iFilters { Param( [string] $Computer )
$hashtable = @{}
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer)
$regKey= $reg.OpenSubKey("SOFTWARE\Classes")
if ($regKey.SubKeyCount) {
foreach ($rkey in $regKey.GetSubKeyNames()) {
$clsids = $reg.OpenSubKey("SOFTWARE\Classes\$rkey\CLSID")
if ($clsids.ValueCount) {
foreach ($name in $clsids.GetValueNames()) {
$clsid = $clsids.GetValue($name)
$ph = $reg.OpenSubKey("SOFTWARE\Classes\CLSID\$clsid\PersistentHandler")
if ($ph.ValueCount) {
$phGuid = $ph.GetValue('')
$if = $reg.OpenSubKey("SOFTWARE\Classes\CLSID\$phGuid\PersistentAddinsRegistered\{89BCB740-6119-101A-BCB7-00DD010655AF}")
if ($if.ValueCount) {
$ifGuid = $if.GetValue('')
$ifDLL = $reg.OpenSubKey("SOFTWARE\Classes\CLSID\$ifGuid\InprocServer32")
$iFilter = $ifDLL.GetValue('')
$hashtable.Add($rKey,$iFilter)
}
}
}
}
}
}
$hashtable.GetEnumerator() | sort value -descending
}
function Get-SQL-Version { Param( [string] $Computer )
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
$SQLserver = new-object ("Microsoft.SqlServer.Management.Smo.Server") $computer | select name, @{name='Version';Expression={$_.information.version}}
$ServerName = $SQLserver.Name
$SQLversion = $SQLserver.Version
return $SQLversion
}
function Get-OSVersionInfo { Param([string] $Computer)
$WMIClass = 'Win32_OperatingSystem'
$OSInfo = Get-WmiObject -computer $Computer -Class $WMIClass
$OSVersion = $OSInfo.Version
$OSServicePack = $OSInfo.ServicePackMajorVersion
$VersionInfo = "$OSVersion $OSServicePack"
return $VersionInfo
}
function Get-OSInstalledRAM { Param([string] $Computer)
$WMIClass = 'Win32_OperatingSystem'
$OSInfo = Get-WmiObject -computer $Computer -Class $WMIClass
$OSInstalledRAM = $OSInfo.TotalVisibleMemorySize
Return $OSInstalledRAM
}
function Get-OSLangPacks { Param([string] $Computer)
$WMIClass = 'Win32_OperatingSystem'
$OSInfo = Get-WmiObject -computer $Computer -Class $WMIClass
$OSLocale = $OSInfo.Locale
$OSLanguage = $OSInfo.OSLanguage
$OSLangPacks = $OSInfo.MUILanguages
$OSLangPacksCount = $OSInfo.MUILanguages.Count
if ($OSLangPacksCount -gt 0) {
Write-Output "$OSLangPacksCount Language Packs installed!"
}
else {
Write-Output "NO language Packs installed."
}
foreach ($pack in $OSLangPacks) {
Write-Output $pack
}
Write-Output "OS Locale: $OSLocale"
Write-Output "OS Language: $OSLanguage"
}
function Get-Farm-Info {
#
# connect to the farm
#
$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()
$ver = $SPfarm.BuildVersion
Write-Output "_____________________________________________"
Write-Output "Farm Version: $ver"
Write-Output " "
$SP2007 = ($ver.Major -EQ 12)
$SP2010 = ($ver.Major -EQ 14)
#
# list the servers in the farm
#
foreach ($SPserver in $SPfarm.Servers) {
$SrvrName = $SPserver.Name
$SrvrRole = $SPserver.Role
Write-Output "Server: $SrvrName Role: $SrvrRole"
$SPServiceInstanceCollection = $SPServer.ServiceInstances
foreach ($SPServiceInstance in $SPServiceInstanceCollection) {
$SrvcName = $SPServiceInstance.TypeName
$Hidden = $SPServiceInstance.Hidden
if (-not $hidden) {
Write-Output " $SrvcName"
}
}
}
Write-Output " "
#
# Solutions in the Farm
#
$SPSolutionCollection = $SPfarm.Solutions
$SolutionCount = $SPSolutionCollection.Count
Write-Output "Solutions in Farm: $SolutionCount"
foreach ($SPsolution in $SPSolutionCollection) {
$SolutionName = $SPsolution.DisplayName
$SolutionGUID = $SPsolution.Id
$SPdeployedServers = $SPsolution.DeployedServers
$SPdeployedWebApps = $SPSolution.DeployedWebApplications
Write-Output " $SolutionGUID : $SolutionName"
if ($SPSolution.Deployed) {
Write-Output " Deployed to:"
foreach ($SPserver in $SPdeployedServers) {
$SrvrName = $SPserver.Name
Write-Output " $SrvrName"
}
foreach ($SPWebApplication in $SPdeployedWebApps) {
$WebAppName = $SPWebApplication.DisplayName
Write-Output " $WebAppName"
}
}
}
Write-Output " "
#
# all Features in the Farm.
#
$SPFeatureDefinitionCollection = $SPFarm.FeatureDefinitions
$FeatureCount = $SPFeatureDefinitionCollection.Count
Write-Output "Features in Farm: $FeatureCount"
foreach ($SPFeatureDefinition in $SPFeatureDefinitionCollection) {
$FeatureName = $SPFeatureDefinition.DisplayName
$FeatureGUID = $SPFeatureDefinition.Id
$FeatureScope = $SPFeatureDefinition.Scope
$output = " {0,-16} {1} {2}" -F $FeatureScope, $FeatureGUID, $FeatureName
Write-Output $output
}
Write-Output " "
#
# AAM's
#
$SPAlternateUrlCollectionManager = $SPfarm.AlternateUrlCollections
foreach ($SPAlternateUrlCollection in $SPAlternateUrlCollectionManager) {
foreach ($SPAlternateUrl in $SPAlternateUrlCollection) {
$UrlZone = $SPAlternateUrl.UrlZone
$IncomingUrl = $SPAlternateUrl.IncomingUrl
$OutgoingUrl = $SPAlternateUrl.Uri
$output = " AAM ({0}) {1,-24} {2}" -F $UrlZone,$IncomingUrl,$OutgoingUrl
Write-Output $output
}
}
Write-Output " "
$SPServiceCollection = $SPfarm.Services
$FarmGUID = $SPfarm.ID
$ServerContext = [Microsoft.Office.Server.ServerContext]::Default
$ServerType = [Reflection.Assembly]::GetAssembly($ServerContext.GetType()).GetType("Microsoft.Office.Server.Administration.ServerFarm")
$ServerFarm = $SPfarm.GetObject("",$FarmGUID,$ServerType)
if ($SP2010) {
$SPServiceApplicationProxyGroupCollection = $SPfarm.ServiceApplicationProxyGroups
foreach ($SPServiceApplicationProxyGroup in $SPServiceApplicationProxyGroupCollection) {
$SPproxyGroupName = $SPServiceApplicationProxyGroup.Name
Write-Output "Proxy Group: '$SPproxyGroupName'"
$SPServiceApplicationProxyCollection = $SPServiceApplicationProxyGroup.Proxies
if ($SPServiceApplicationProxyCollection) {
Write-Output "Service Application Proxies:"
foreach ($SPServiceApplicationProxy in $SPServiceApplicationProxyCollection) {
$ProxyName = $SPServiceApplicationProxy.Name
$ProxyGUID = $SPServiceApplicationProxy.Id
$ProxyStatus = $SPServiceApplicationProxy.Status
$output = " {0,-40} {1} {2}" -F $ProxyName, $ProxyGUID, $ProxyStatus
Write-Output $output
}
}
}
}
################ SSP info ################
#
# all this to get access to the SSP (whew!)
# will have to figure out all the new 2010 services at some point
if ($SP2007) {
$SSPcollection = $ServerFarm.GetType().GetProperty("SharedResourceProviders").GetValue($ServerFarm, $null);
$SSPcount = $SSPcollection.count
Write-Output "SSP count: $SSPCount"
foreach ($SSP in $SSPcollection) {
$SSPname = $SSP.name
$SSPguid = $SSP.AdministrationSiteId
$SSPdb = $SSP.ServiceDatabase
$SSPdbName = $SSPdb.name
$SSPsite = new-object Microsoft.Sharepoint.SPsite($SSPguid)
#
# identify the SSP
#
$SSPurl = $SSPsite.WebApplication.GetResponseUri("Default").AbsoluteUri + "ssp/admin"
Write-Output "'$SSPname' via '$SSPurl' in '$SSPdbName'"
$SSPcontext=[Microsoft.Office.Server.ServerContext]::GetContext($SSPsite)
$SPsearchcontext=[Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($SSPContext)
#
# audiences
#
$audManager=New-Object Microsoft.Office.Server.Audience.AudienceManager($SSPContext);
$audCollection=$audManager.Audiences;
if ($audCollection.Count) {
$audCount = $audCollection.Count
Write-Output "Audiences: $audCount"
foreach ($aud in $audcollection) {
$AudienceName = $aud.AudienceName
Write-Output " Audience: $AudienceName"
}
}
#
# scopes - I am referring to the SSP search
#
$scopes = new-object Microsoft.Office.Server.Search.Administration.Scopes($SPsearchContext)
$allScopes = $scopes.AllScopes
if ($allscopes.count) {
$scopeCount = $allscopes.count
Write-Output "Scopes: $scopeCount"
foreach ($Scope in $allScopes) {
$ScopeName = $Scope.Name
Write-Output " Scope: $ScopeName"
}
}
#
# content sources - I am referring to the SSP search
#
$SrchContent = new-object Microsoft.Office.Server.Search.Administration.Content($SPsearchContext)
$SrchContentSources = $SrchContent.ContentSources
if ($SrchContentSources.Count) {
$csCount = $SrchContentSources.Count
Write-Output "Crawl content sources: $csCount"
foreach ($ContentSrc in $SrchContentSources) {
$ConSrcName = $ContentSrc.Name
Write-Output " Source: $ConSrcName"
}
}
#
# crawl rules
#
$SearchCrawlRuleCollection = $SrchContent.CrawlRules
if ($SearchCrawlRuleCollection.Count) {
Write-Output "Crawl Rules"
$CrawlRules = $SearchCrawlRuleCollection.GetEnumerator()
foreach ($CrawlRule in $CrawlRules) {
$CrType = $CrawlRule.Type
$CrPath = $CrawlRule.Path
Write-Output " $CrType : $CrPath"
}
Write-Output " "
}
#
# user profiles
#
$fDumpUserProfiles = $false
$UserProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext)
$MySitesURL = $UserProfileManager.MySiteHostUrl
Write-Output "MySites: $MySitesURL"
if ($fDumpUserProfiles) {
$Profiles = $UserProfileManager.GetEnumerator()
foreach ($UserProfile in $Profiles ) {
$ProfName = $UserProfile.MultiloginAccounts
Write-Output "Profile: $ProfName"
}
}
}
# endfor each $SSP...
}
#endif $SP2007
Write-Output " "
# BDC namespace will need to know the SSP name.
# Microsoft.Office.Server.ApplicationRegistry.Administration
$DBName = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("Name")
$DBID = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("Id")
$DBCurrentSiteCount = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("CurrentSiteCount")
$DBMaximumSiteCount = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("MaximumSiteCount")
$DBIsReadOnly = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("IsReadOnly")
###################### web services / web applications ###############
#
# OK, now walk the hierarchy
#
$SPWebServices = new-object Microsoft.Sharepoint.Administration.SPWebServiceCollection($SPFarm)
$SumContentDatabases = 0
foreach ($SPWebService in $SPWebServices) {
$SPWebSvcName = $SPWebService.Name
#
# quota templates
#
$QuotaTemplates = $SPwebService.QuotaTemplates
$QuotaCount = $QuotaTemplates.count
Write-Output " "
Write-Output "There are $QuotaCount quota templates in $SPWebSvcName"
if ($QuotaCount -gt 0) {
for ($i=0; $i -le ( $QuotaCount - 1 ); $i++) {
$QT = $QuotaTemplates[$i].Name
Write-Output " Template: $QT"
}
}
$SPWebApplicationCollection = $SPWebService.WebApplications
#
# walk each web-app
#
foreach ($SPWebApplication in $SPWebApplicationCollection) {
$WebAppProps = $SPWebApplication.Properties
$Special = ""
$IsCA = $SPWebApplication.IsAdministrationWebApplication
If ($IsCA) {
$Special = " (CA) "
}
if ($WebAppProps.count -gt 0) {
if ($WebAppProps.ContainsKey("Microsoft.Office.Server.SharedResourceProvider")) {
$Special = " (SSP) "
}
}
$WebAppName = $SPWebApplication.Name
$DefaultQuotaTemplate = $SPWebApplication.DefaultQuotaTemplate
$SPSites = $SPWebApplication.Sites
$SPSiteCount = $SPSites.count
Write-Output " "
Write-Output "Web-App: $Special '$WebAppName' contains $SPSiteCount collections"
Write-Output " Default Quota Template is '$DefaultQuotaTemplate'"
#
# App pool
#
$SPApplicationPool = $SPWebApplication.ApplicationPool
$AppPoolName = $SPApplicationPool.Name
$AppPoolAccount = $SPApplicationPool.Username
Write-Output " App-pool: '$AppPoolName' Account: '$AppPoolAccount'"
#
# IIS
#
$SPIisSettings = $SPWebApplication.IisSettings
$IisAuthMode = $SPIisSettings.get_Item(0).AuthenticationMode
$IisAnon = $SPIisSettings.get_Item(0).AllowAnonymous
$IisDisableKerb = $SPIisSettings.get_Item(0).DisableKerberos
$IisUseBasic = $SPIisSettings.get_Item(0).UseBasicAuthentication
$IisUseWindows = $SPIisSettings.get_Item(0).UseWindowsIntegratedAuthentication
$IisPath = $SPIisSettings.get_Item(0).Path.Fullname
Write-Output " IISpath is: $IisPath"
Write-Output " AuthMode : $IisAuthMode"
Write-Output " 'Anon' : $IisAnon"
Write-Output " 'Basic' : $IisUseBasic"
Write-Output " 'Integrated' : $IisUseWindows"
Write-Output " 'DisableKerberos' : $IisDisableKerb"
Write-Output " "
#
# all Features in the Web-app.
#
$SPFeatureCollection = $SPWebApplication.Features
$FeatureCount = $SPFeatureCollection.Count
Write-Output " Features in Web-App: $FeatureCount"
foreach ($SPFeature in $SPFeatureCollection) {
$SPFeatureDefinition = $SPFeature.Definition
$FeatureGUID = $SPFeatureDefinition.Id
$FeatureScope = $SPFeatureDefinition.Scope
$FeatureDispName = $SPFeatureDefinition.DisplayName
$output = " {0,-16} {1} {2}" -F $FeatureScope, $FeatureGUID, $FeatureDispName
Write-Output $output
}
Write-Output " "
#
# DB info
#
$ContentDBCollection = $SPWebApplication.ContentDatabases
foreach($ContentDB in $ContentDBCollection) {
$CurrentDBName = $DBName.GetValue($ContentDB, $null)
$CurrentDBID = $DBID.GetValue($ContentDB, $null)
$CurrentDBCurrentSiteCount = $DBCurrentSiteCount.GetValue($ContentDB, $null)
$CurrentDBDBMaximumSiteCount = $DBMaximumSiteCount.GetValue($ContentDB, $null)
$CurrentDBIsReadOnly = $DBIsReadOnly.GetValue($ContentDB, $null)
# flag this!
Write-Output " DB: $CurrentDBName ReadOnly: $CurrentDBIsReadOnly"
}
$SumContentDatabases++
#
# blocked file types
#
$fDumpBlockFileTypes = $false
if ($fDumpBlockFileTypes) {
$BlockedFileTypes = $SPWebApplication.BlockedFileExtensions
foreach ($FileType in $BlockedFileTypes) {
Write-Output "Blocked: $FileType"
}
}
#
# walk all sites and webs
#
try {
foreach ($SPSite in $SPSites) {
#
# all Features in the Site Collection.
#
$SPFeatureCollection = $SPSite.Features
$FeatureCount = $SPFeatureCollection.Count
Write-Output " Features in Site: $FeatureCount"
foreach ($SPFeature in $SPFeatureCollection) {
$SPFeatureDefinition = $SPFeature.Definition
$FeatureGUID = $SPFeatureDefinition.Id
$FeatureScope = $SPFeatureDefinition.Scope
$FeatureDispName = $SPFeatureDefinition.DisplayName
$output = " {0,-6} {1} {2}" -F $FeatureScope, $FeatureGUID, $FeatureDispName
Write-Output $output
}
Write-Output " "
foreach ($SPweb in $SPSite.AllWebs) {
$webTemplateID = $SPWeb.WebTemplateId
$webTemplate = $SPWeb.WebTemplate
Write-Output "Web TemplateID = $webTemplateID = '$webTemplate'"
if ($SPweb.IsRootWeb -eq $true) {
#
# Site Collection Admins
#
Write-Output " the root collection is: $SPweb"
#
# all Features in the WEB.
#
$SPFeatureCollection = $SPweb.Features
$FeatureCount = $SPFeatureCollection.Count
Write-Output " Features in WEB: $FeatureCount"
foreach ($SPFeature in $SPFeatureCollection) {
$SPFeatureDefinition = $SPFeature.Definition
$FeatureGUID = $SPFeatureDefinition.Id
$FeatureScope = $SPFeatureDefinition.Scope
$FeatureDispName = $SPFeatureDefinition.DisplayName
$output = " {0,-6} {1} {2}" -F $FeatureScope, $FeatureGUID, $FeatureDispName
Write-Output $output
}
Write-Output " "
$webURL = $SPWeb.Url
$admins = $SPweb.SiteAdministrators;
foreach ($user in $admins) {
write-output " Admin: $user"
}
}
else {
#
# explicit permissions!
#
if ($SPweb.HasUniqueRoleAssignments -eq $true) {
$webURL = $SPWeb.Url
Write-Output "____ NOT inheriting! $webURL"
}
}
#
# check for long file names? (>220 chars)
#
#
# checked-out docs (will only appear if the doclib has "Require Check Out" set to YES)
#
$SPBaseTypeDocumentLibrary = [Microsoft.SharePoint.SPBaseType]::DocumentLibrary
$SPdocLibs = $SPWeb.GetListsOfType($SPBaseTypeDocumentLibrary)
foreach ($SPdocLib in $SPdocLibs) {
if ($SPdocLib.ForceCheckout -eq $true) {
$SPCheckedOutFiles = $SPdocLib.CheckedOutFiles
foreach ($SPCheckedOutFile in $SPCheckedOutFiles) {
$DirName = $SPCheckedOutFile.DirName
$LeafName = $SPCheckedOutFile.LeafName
$CheckedOutBy = $SPCheckedOutFile.CheckedOutBy
Write-Output "Awaiting check-in: DocLib '$DirName' of file '$LeafName' by User $CheckedOutBy"
}
}
}
}
}
}
catch {
"Error caught: {0}" -f $Error[0]
}
}
}
}
set-psdebug -strict
Get-Farm-Info
Comments
Anonymous
November 08, 2010
Nice collection of code blocks to extract info about farm all into one script. I would appreciate if you can post link to downlaod the PowerShell file. For some reason my script is broken when doing a copy paste no big deal to figure it out, but it might be helpful for other people who might want to use this. Sameer Dhoot | http://sharemypoint.inAnonymous
January 07, 2011
Great work! I testet the script and it shows a lot of details, but i have one problem. The following statement does not return anything: $ServerFarm = $SPfarm.GetObject("",$FarmGUID,$ServerType) Its from this codeblock: ################ SSP info ################
all this to get access to the SSP (whew!)
$FarmGUID = $SPfarm.ID $ServerContext = [Microsoft.Office.Server.ServerContext]::Default $ServerType = [Reflection.Assembly]::GetAssembly($ServerContext.GetType()).GetType("Microsoft.Office.Server.Administration.ServerFarm") $ServerFarm = $SPfarm.GetObject("",$FarmGUID,$ServerType) $SSPcollection = $ServerFarm.GetType().GetProperty("SharedResourceProviders").GetValue($ServerFarm, $null); $SSPcount = $SSPcollection.count write-host "SSP count: $SSPCount" foreach ($SSP in $SSPcollection) { $SSPname = $SSP.name $SSPguid = $SSP.AdministrationSiteId $SSPdb = $SSP.ServiceDatabase $SSPdbName = $SSPdb.name $SSPsite = new-object Microsoft.Sharepoint.SPsite($SSPguid) I need info on configured Audiences, and that exact bit of info requires the above statement to work.