3

When I tried enabling sideloading for one of my tenant using powershell, it failed with the following exception:

Exception calling ".ctor" with "1" argument(s): "Value does not fall within the expected range.

Any help/suggestion for troubleshooting this would be highly appreciated.

2

2 Answers 2

2

Here is the working powershell script which I always use to enable the Side Loading feature.

$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'
$siteurl = 'SITEURL'
$username = 'USERNAME'
$password = ConvertTo-SecureString -String 'PASSWORD' -AsPlainText -Force
$outfilepath = $siteurl -replace ':', '_' -replace '/', '_'
[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
$sideLoadingEnabled = [Microsoft.SharePoint.Client.appcatalog]::IsAppSideloadingEnabled($cc);
$cc.ExecuteQuery()
if($sideLoadingEnabled.value -eq $false) {
    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, $false, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
    $cc.ExecuteQuery();
    Write-Host -ForegroundColor Green 'SideLoading feature enabled on site' $siteurl
}
Else
{
    Write-Host -ForegroundColor Green 'SideLoading feature is already enabled on site' $siteurl
}
1
  • This is somewhat similar to one found on the mentioned blog. Also I have tested the same script found in the blog for another tenant and it is working fine for that tenant.
    – mohd tahir
    Commented Oct 13, 2017 at 3:46
2

Figured it out. It was my mistake. Missed appending 'https' in the starting of the URL.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.