Sideloading of apps is not enabled on this site

SideLoading of apps is disabled by default on SharePoint sites. So in order to publish our app directly from visual studio, we need to enable this option. However, do remember that Sideloading apps is a developer/test feature not intended for production use.Before proceeding further please make sure that you have already installed the Sharepoint Online Management Shell. Next follow the steps described below:-

Enable SideLoading

* Save the following code to your machine as “EnableSideLoading.ps1“.


$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
    $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
    }
}
 
Catch { 
    Write-Host -ForegroundColor Red `
      'Error encountered when trying to enable SideLoading feature' `
      $siteurl, ':' $Error[0].ToString();
}
* Execute “EnableSideLoading.ps1” from PowerShell.
* Provide your Credentials.
* That’s it. You’ll now be able to install app directly from Visual Studio.

Disable SideLoading

Once your job  is done, make sure to disable this option. To do that run the following script from PowerShell just as it has been described above.

$programFiles = [environment]::getfolderpath("programfiles")

add-type -Path $programFiles'\SharePoint Online Management Shell\' + `
 Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'

Write-Host 'To disable 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
}
 
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
 
    $site = $cc.Site;
    
    $sideLoadingEnabled = `
    [Microsoft.SharePoint.Client.appcatalog]::IsAppSideloadingEnabled($cc);
    
    $cc.ExecuteQuery()
    
    if($sideLoadingEnabled.value -eq $false)
    {
      Write-Host -ForegroundColor Green `
        'SideLoading is alreday disabled on site' $siteurl
        }
       else
       {
      Write-Host -ForegroundColor Yellow `
        'Disabling SideLoading feature on site' $siteurl
      $sideLoadingGuid = `
        new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"
      $site.Features.Remove($sideLoadingGuid, $true);
      $cc.ExecuteQuery();
      Write-Host -ForegroundColor Green `
        'SideLoading disabled on site' $siteurl
        }

} catch {
    Write-Host -ForegroundColor Red `
      'Error encountered when trying to disable side loading features' `
      $siteurl, ':' $Error[0].ToString();
}
 

For further details, visit the following site:
http://blogs.msdn.com/b/officeapps/archive/2013/12/10/enable-app-sideloading-in-your-non-developer-site-collection.aspx

Get Available PowerShell Commands for SharePoint on Client-Side

Needless to say, that on Client Side, we get a limited scope of running various SharePoint commands. As a result there aren’t much cmdlets for the Client Side. So how do you know what are the available commands that might come handy while executing cmdlets remotely? Simply run the following command in PowerShell or SharePoint Online Management Shell.
get-command | Where-Object { $_.ModuleName -eq "Microsoft.Online.SharePoint.PowerShell" }

A sample list of available cmdlets are displayed in the following screenShot.