Publishing feature is showing activated when it is not

Tanmoy Das 806 Reputation points
2021-01-20T23:50:00.713+00:00

Hi Guys,

Writing a script to check whether SharePoint publishing feature is active or not at the web level.

$webpubfeature=Get-PnPFeature -scope Web -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb
if($webpubfeature.DefinitionId)
{
$Web.url
}

It is showing webs for which the publishing feature is not even active.
Any idea how to get the correct result

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JoyZ 18,111 Reputation points
    2021-01-21T02:48:37.82+00:00

    Hi anonymous user,

    Try to add "-eq $null" as follows:

    if($webpubfeature.DefinitionId -eq $null)  
    

    If the site has a publishing function activated, the site URL will be output.


    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.