Powershell Scipt to Find Farm Scoped Features

  1. $LogTime = Get-Date -Format yyyy-MM-dd_hh-mm  
  2. $LogFile = ".\FarmScopedFeaturePatch-$LogTime.rtf"  
  3. # Add SharePoint PowerShell Snapin  
  4.   
  5.   
  6. if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {  
  7.    Add-PSSnapin Microsoft.SharePoint.Powershell  
  8. }  
  9.   
  10. $scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent  
  11. Set-Location $scriptBase  
  12.  
  13.  
  14. #Deleting any .rtf files in the scriptbase location  
  15. $FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf  
  16. if($FindRTFFile)  
  17. {  
  18.    foreach($file in $FindRTFFile)  
  19.    {  
  20.       remove-item $file  
  21.    }  
  22. }  
  23.   
  24.   
  25. start-transcript $logfile  
  26.   
  27.   
  28. try {  
  29.   
  30.    Write-Verbose "Getting Farm Scope Features..."  
  31.   
  32.    $features = Get-SPFeature -Farm -Limit All | Sort-Object DisplayName  
  33.   
  34.    Write-Output $features  
  35. }  
  36. catch [Exception] {  
  37.    Write-Error $Error[0]  
  38.    $err = $_.Exception  
  39.    while ( $err.InnerException ) {  
  40.       $err = $err.InnerException  
  41.       Write-Output $err.Message  
  42.    }  
  43. }  
  44.   
  45. stop-transcript