$LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
$LogFile = ".\FeaturePackedInSolutionPatch-$LogTime.rtf"
# Add SharePoint PowerShell Snapin
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
Add-PSSnapin Microsoft.SharePoint.Powershell
}
$scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
Set-Location $scriptBase
#Deleting any .rtf files in the scriptbase location
$FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf
if($FindRTFFile)
{
foreach($file in $FindRTFFile)
{
remove-item $file
}
}
start-transcript $logfile
$solution = ""
[string]$solution = Read-Host "Enter the Solution name: [e.g. MyCustomSolution.wsp]"
try {
Write-Verbose "Getting solution features ..."
$features = @()
$solution1 = Get-SPSolution -Identity $solution -ErrorAction SilentlyContinue
foreach ($grp in Get-SPFeature | where {$_.SolutionID -eq $solution1.id} | Group-Object SolutionId) {
foreach ($fd in $grp.Group | sort DisplayName ) {
$feature = New-Object -TypeName PSObject -Property @{
SolutionName = $solution1.Name
SolutionId = $solution1.Id
FeatureName = $fd.DisplayName
FeatureId = $fd.Id
FeatureScope = $fd.Scope
}
$features += $feature
}
}
Write-Output $features
}
catch [Exception] {
Write-Error $Error[0]
$err = $_.Exception
while ( $err.InnerException ) {
$err = $err.InnerException
Write-Output $err.Message
}
}This script lists out the features that are packed in the given SharePoint solution.
