I was trying to setup side-loading using the following sideload.ps1 script:
#CODE STARTS HERE
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'
Write-Host 'To enable SharePoint app sideLoading, enter Site Url, username and password'
$siteurl = Read-Host 'Site Url'
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString 'Password'
if ($siteurl -eq '')
{
$siteurl = 'https://mytenant.sharepoint.com/sites/mysite'
$username = 'me@mytenant.onmicrosoft.com'
$password = ConvertTo-SecureString -String 'mypassword!' -AsPlainText -Force
}
$outfilepath = $siteurl -replace ':', '_' -replace '/', '_'
try
{
[Microsoft.SharePoint.Client.ClientContext]$cc = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)
[Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$cc.Credentials = $spocreds
Write-Host -ForegroundColor Yellow 'SideLoading feature is not enabled on the site:' $siteurl
$site = $cc.Site;
$sideLoadingGuid = new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"
$site.Features.Add($sideLoadingGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
$cc.ExecuteQuery();
Write-Host -ForegroundColor Green 'SideLoading feature enabled on site' $siteurl
#Activate the Developer Site feature
}
catch
{
Write-Host -ForegroundColor Red 'Error encountered when trying to enable SideLoading feature' $siteurl, ':' $Error[0].ToString();
}
#CODE ENDS HERE
I entered the following into the script prompts:
- http://spdev.testsite.com
- my.name@spdev.testsite.com
- mypassword
And got the following output, followed by an error:
To enable SharePoint app sideLoading, enter Site Url, username and password
SideLoading feature is not enabled on the site: http://spdev.exova.com
DefinitionId :
Context : Microsoft.SharePoint.Client.ClientContext
Tag :
Path : Microsoft.SharePoint.Client.ObjectPathMethod
ObjectVersion :
ServerObjectIsNull :
TypedObject : Microsoft.SharePoint.Client.Feature
Error encountered when trying to enable SideLoading featurehttp://spdev.testsite.com : Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (401) Unauthorized."
I should have full administrator rights to the sharepoint server. So am I doing something wrong in the input? Is this login ID the wrong thing to use, if so what should I be using as a login ID? Or is it simply saying that I really don’t have the right authorisation
to do this? If so what authorisation do I need?
This is failing at the $cc.ExecuteQuery();command, so it is taking my user ID and password without any problem.
I just found a page that says 'You must be a Tenant Admin to activate this feature.' so what is a Tenant Admin, and how do I see if I am one? I added myself as a 'Site Collection Administrator' in Central Administration, but that didn't
seem to make any difference.