Script error when tried to get the sites list where particular feature should be activated

sns 9,236 Reputation points
2021-06-16T14:30:12.69+00:00

Script error when tried to get the sites list where particular feature should be activated
Below is the error . Also want to export results to excel. Please help
106293-scripterror.png

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,934 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. CaseyYang-MSFT 10,426 Reputation points
    2021-06-17T09:05:00.733+00:00

    Hi @sns

    Per my test, you could try the following PowerShell codes to check if feature is activated. Note: Please make sure the feature display name is right.

    PowerShell codes:

    Add-PSSnapin "Microsoft.SharePoint.PowerShell"  
      
    $web = Get-SPWebApplication -Identity "web application URL"     
    Foreach($site in $web.Sites)     
    {     
      $feature = Get-SPFeature -Site $site | Where-Object {$_.DisplayName -eq "the feature you want to check"    
    }     
      if($feature -ne $null)     
      {     
        Write-Host $site.RootWeb.Url " - Activated"     
      }     
      if($feature -eq $null)     
      {     
        Write-Host $site.RootWeb.Url " - Deavtivated"     
      }   
    }  
    

    106510-1.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.