Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
How activate a Web level Feature on all the subwebs in a WebApplication using Powershell - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2013-06-13

Try

{

$webApplicationURL = $args[0]

$featureFolderName = "Web level FeatureName"

$webApp = Get-SPWebApplication $webApplicationURL

if($webApp -ne $null)

{

 foreach($siteColl in $webApp.Sites)

 {

   if($siteColl -ne $null)

   {

   foreach($subWeb in $siteColl.AllWebs)

   {

    if($subWeb -ne $null)

    {

     # Print each Subsite

     Write-Host $subWeb.Url

     #Get Feature ID based on the Feature Name

     $FeatureID = Get-SPFeature -Web $subWeb.Url | Where {$_.DisplayName -eq $featureFolderName}

     if($FeatureID -ne $null)

     {

      #Check whether Feature to be activated is already activated for this subsite

      if (Get-SPFeature -Web $subWeb.Url | Where {$_.ID -eq $FeatureID.Id})

      {

       Write-Host $featureFolderName "is already activated at :" $subWeb.Url

                   Enable-SPFeature -Identity $featureFolderName -URL $subWeb.Url -Force 

                   Write-Host $featureFolderName "is Re-activated at :" $subWeb.Url

      }

      else

      {

       Enable-SPFeature -Identity $featureFolderName -Confirm:$false -Url $subWeb.url

       Write-Host $featureFolderName "has been activated at :" $subWeb.url

      }

     }

     $subWeb.Dispose()

    }

    else

    {

     Echo $subWeb "does not exist"

    }

   }

   $siteColl.Dispose()

  }

  else

  {

   Echo $siteColl "does not exist"

  }

 }

}

else

{

Echo $webApplicationURL "does not exist "

}

}

catch

{

   Write-Host -Object "Error occurred while running this script "

}

 

(Visited 312 times, 1 visits today)

About the author 

Anil Lakhagoudar

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.