Created
December 27, 2017 14:27
-
-
Save Vintaurus/aad6b418e9dd4a6fcbcc90351862d511 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Variables | |
$siteUrl = "http://sharepoint2013/organization/Nav_Rep_WithoutVariation_De" | |
$featureID = [GUID]("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") | |
#endregion | |
#region Add references to SharePoint client assemblies - required for CSOM | |
Add-Type -Path "Microsoft.SharePoint.Client.dll" | |
Add-Type -Path "Microsoft.SharePoint.Client.Runtime.dll" | |
#endregion | |
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) | |
$context.ExecuteQuery() | |
$web = $context.Web | |
$context.Load($web) | |
Try | |
{ | |
$siteFeatures = $context.Site.Features | |
$context.Load($siteFeatures) | |
$context.ExecuteQuery() | |
$siteFeatures.Add($featureID, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) | |
$context.ExecuteQuery() | |
Write-Host "Feature '$featureID' successfully activtated by '$siteUrl' " | |
} | |
Catch | |
{ | |
Write-Host "No activated by '$item.Name'" | |
} | |
Read-Host "Press enter key to continue" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment