############################################################################################################################################
# GetAllFeature_Scope_in_Total_Farm_ActiveStatus
# Parameters: N/A
# Created By : Suresh Kumar Durairaj
############################################################################################################################################
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }
$host.Runspace.ThreadOptions = "ReuseThread"
$resultsarray =@()
#Function that gets the size of all the content databases
function Get-ContentDBSizes
{
try
{
# $ContentDatabaseInfo= "features_Title" + "," + "feature_Hidden"+ ","+"Scope"+ ","+"Feature_ID"
# $ContentDatabaseInfo
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Farm" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -Farm | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value ""
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -Farm | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value ""
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
$webapps = get-spwebapplication
# Loop through each Web App
foreach ($webapp in $webapps)
{
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "WebApplication" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -WebApplication $webapp.URL | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName), Url::- $webapp.URL " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $webapp.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -WebApplication $webapp.URL | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $webapp.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
}
foreach ($webapp in $webapps)
{
foreach ($site in $webapp.Sites)
{
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Site" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -Site $site.URL | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName), Url::- $webapp.URL " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $site.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -Site $site.URL | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $site.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
}
}
foreach ($webapp in $webapps)
{
foreach ($site in $webapp.Sites)
{
if($site.AllWebs.Count -gt 0)
{
foreach ($subsite in $site.AllWebs)
{
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Web" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -Web $subsite.URL | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName), Url::- $webapp.URL " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $subsite.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -Web $subsite.URL | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $subsite.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
}
}
}
}
$resultsarray| Export-csv "C:\Temp\GetAllFeature_Scope_in_Total_Farm_ActiveStatus.csv" -notypeinformation
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}
Start-SPAssignment –Global
Get-ContentDBSizes
Stop-SPAssignment –Global
Remove-PsSnapin Microsoft.SharePoint.PowerShell
# GetAllFeature_Scope_in_Total_Farm_ActiveStatus
# Parameters: N/A
# Created By : Suresh Kumar Durairaj
############################################################################################################################################
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }
$host.Runspace.ThreadOptions = "ReuseThread"
$resultsarray =@()
#Function that gets the size of all the content databases
function Get-ContentDBSizes
{
try
{
# $ContentDatabaseInfo= "features_Title" + "," + "feature_Hidden"+ ","+"Scope"+ ","+"Feature_ID"
# $ContentDatabaseInfo
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Farm" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -Farm | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value ""
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -Farm | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value ""
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
$webapps = get-spwebapplication
# Loop through each Web App
foreach ($webapp in $webapps)
{
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "WebApplication" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -WebApplication $webapp.URL | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName), Url::- $webapp.URL " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $webapp.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -WebApplication $webapp.URL | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $webapp.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
}
foreach ($webapp in $webapps)
{
foreach ($site in $webapp.Sites)
{
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Site" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -Site $site.URL | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName), Url::- $webapp.URL " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $site.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -Site $site.URL | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $site.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
}
}
foreach ($webapp in $webapps)
{
foreach ($site in $webapp.Sites)
{
if($site.AllWebs.Count -gt 0)
{
foreach ($subsite in $site.AllWebs)
{
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Web" } # Farm, WebApp, Site and Web
if ($siteFeatures -ne $null)
{
foreach ($feature in $siteFeatures)
{
# -Site can be replace by -Farm (without url), -WebApp, -Web
if ((Get-SPFeature -Web $subsite.URL | Where-Object {$_.Id -eq $feature.id}) -ne $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName), Url::- $webapp.URL " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "Yes"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $subsite.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
elseif ((Get-SPFeature -Web $subsite.URL | Where-Object {$_.Id -eq $feature.id}) -eq $null)
{
# active feature
Write-Host "$($feature.Scope), feature:- $($feature.DisplayName) " -ForeGroundColor DarkRed
$contactObject = new-object PSObject
# Add our data to $contactObject as attributes using the add-member commandlet
$contactObject | add-member -membertype NoteProperty -name "features_Title" -Value $feature.DisplayName
$contactObject | add-member -membertype NoteProperty -name "feature_Hidden" -Value $feature.Hidden
$contactObject | add-member -membertype NoteProperty -name "Scope" -Value $feature.Scope
$contactObject | add-member -membertype NoteProperty -name "Feature ID" -Value $feature.ID
$contactObject | add-member -membertype NoteProperty -name "Activation status" -Value "No"
$contactObject | add-member -membertype NoteProperty -name "Url" -Value $subsite.URL
# Save the current $contactObject by appending it to $resultsArray ( += means append a new element to ‘me’)
$resultsarray += $contactObject
}
}
}
}
}
}
}
$resultsarray| Export-csv "C:\Temp\GetAllFeature_Scope_in_Total_Farm_ActiveStatus.csv" -notypeinformation
}
catch [System.Exception]
{
write-host -f red $_.Exception.ToString()
}
}
Start-SPAssignment –Global
Get-ContentDBSizes
Stop-SPAssignment –Global
Remove-PsSnapin Microsoft.SharePoint.PowerShell
No comments:
Post a Comment