Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Feature Description Feature Scope Feature ID Problem
- PSWApproval Feature Site collection ad739f9e-1525-4dec-a25e-10821ca70c95 Not activated
- GlobalHold Feature Site collection 2a6bf8e8-10b5-42f2-9d3e-267dfb0de8d4 Not activated
- PWAWebParts Feature Site collection 10eb8dad-31aa-4461-9843-27305d0c7c93 Not activated
- PwaIdeaList Feature Site collection ce0143de-6894-428b-9f6b-37bd6848ec26 Not activated
- PWARibbon Feature Site collection 1d253548-c70d-40fd-9930-9d313bedc359 Not activated
- MobileExcelWebAccess Feature Site collection e995e28b-9ba8-4668-9933-cf5c146d7a9f Not activated
- This template can't be used for this site collection until the issues above are resolved.
- #Required Parameters
- $sSiteColUrl = "https://portal.sharepoint.com"
- $sUserName = "admin@portal.com"
- $sFeatureGuid="2a6bf8e8-10b5-42f2-9d3e-267dfb0de8d4"
- $sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString
- #Script that enables a feature in a SPO Site
- # Required Parameters:
- # -> $sUserName: User Name to connect to the SharePoint Online Site Collection.
- # -> $sPassword: Password for the user.
- # -> $sSiteColUrl: SharePoint Online Site Collection
- # -> $sFeatureGuid: GUID of the feature to be enabled
- $host.Runspace.ThreadOptions = "ReuseThread"
- #Definition of the function that allows to enable a SPO Feature
- function Enable-SPOFeature
- {
- param ($sSiteColUrl,$sUserName,$sPassword,$sFeatureGuid)
- try
- {
- #Adding the Client OM Assemblies
- Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.dll"
- Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
- #SPO Client Object Model Context
- $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteColUrl)
- $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUsername, $sPassword)
- $spoCtx.Credentials = $spoCredentials
- Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green
- Write-Host "Enabling the Feature with GUID $sFeatureGuid !!" -ForegroundColor Green
- Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green
- $guiFeatureGuid = [System.Guid] $sFeatureGuid
- #############################################
- # todo: change object: $spoSite=$spoCtx.Site | $spoSite=$spoCtx.Web
- $spoSite=$spoCtx.Site
- # todo: change scope: [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None | Farm | Site | Web
- # https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.featuredefinitionscope.aspx?f=255&MSPPError=-2147217396
- $spoSite.Features.Add($sFeatureGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
- #############################################
- $spoCtx.ExecuteQuery()
- $spoCtx.Dispose()
- }
- catch [System.Exception]
- {
- write-host -f red $_.Exception.ToString()
- }
- }
- #Required Parameters
- $sSiteColUrl = "https://portal.sharepoint.com"
- $sUserName = "admin@portal.com"
- $sFeatureGuid= " e995e28b-9ba8-4668-9933-cf5c146d7a9f"
- $sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString
- Enable-SPOFeature -sSiteColUrl $sSiteColUrl -sUserName $sUserName -sPassword $sPassword -sFeatureGuid $sFeatureGuid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement