Enabling SharePoint App catalogue at site collection level in SharePoint Online

Microsoft SharePoint Logo Sometimes we require to deploy SharePoint apps to a development site collection instead of tenant app catalogue. During those scenarios the following PowerShell command can be used to enable the app catalogue at site collection level.

Please note that you will require SharePoint Online Management Shell for this PowerShell to work. Please refer here for installation.

Enabling site collection app catalogue

Connect-SPOService -Url https://yourtenant-admin.sharepoint.com

# Reference of the site collection where the site collection app catalogue should reside
$site = Get-SPOSite https://yourtenant.sharepoint.com/sites/yoursitecollection
 
# Create app catalogue in the site collection
Add-SPOSiteCollectionAppCatalog -Site $site

Disabling site collection app catalogue

Connect-SPOService -Url https://yourtenant-admin.sharepoint.com

# Reference of the site collection where the site collection app catalogue should reside
$site = Get-SPOSite https://yourtenant.sharepoint.com/sites/yoursitecollection
 
# Remove app catalogue from the site collection
Remove-SPOSiteCollectionAppCatalog -Site $site 

Remove the title banner from SharePoint modern page

Microsoft SharePoint Logo The title banner in the modern pages of SharePoint takes a lot of space.

Even if you try to switch to “Plain” title layout, the title area still will take some space.

To completely remove the space, you can run the following PnP PowerShell command with the ID of the page.

For more about PnP PowerShell, visit this link.

Set-PnPListItem -List SitePages –Identity <id> -Values @{"PageLayoutType"="Home"}

First connect to the site using the following command

Connect-PnPOnline https://tenant.sharepoint.com/sites/site-where-the-page-exists  

Then find out the ID of the page using the following command. This command assumes that the page is located within “SitePage” library.

Get-PnPListItem -List SitePages

Finally set the page’s layout type to “Home” by running the following command.

Set-PnPListItem -List SitePages –Identity <id> -Values @{"PageLayoutType"="Home"}

Now the title area is totally gone.

Logon attempt failed for remote desktop Windows 10

Microsoft Windows 10 Logo

Scenario

  • My remote PC is a Windows 10 Pro v1809.
  • The remote PC Windows user is an Office 365 user.
  • I’m trying to login to my remote PC and I get the error “Logon attempt failed”.
  • The following are the various user IDs I tried and none of them worked.
    • user@domain.com
    • AzureAD\user@domain.com
    • AzureAD\user
The logon attempt failed

Solution

  1. Save an RDP connection as file with parameters like name of the PC.
  2. Open the RDP file using a text editor like notepad.
  3. Modify the entry “authentication level” to “authentication level:i:0”
    1. Make sure the “Allow connections only from computers running Remote Desktop with Network Level Authentication” is unchecked in the remote machine’s settings.
  4. Add the entry “enablecredsspsupport:i:0”.
  5. Now save the file.
  6. Run the RDP file and it should connect to remote machine and show you the login screen of the remote machine
  7. Type in the username as AzureAD\user@domain.com
  8. Password as login password and not the Windows PIN.
  9. Now you should be able to login.

Refer here for more information.

Sharepoint Online’s modern experience web parts and their quivalent classic experience web parts

SharePoint 2013 Logo

SharePoint’s modern experience web parts is an easy and fast way to bring content to the viewer. But at the same time it’s not as configurable or as exhaustive as it is when compared to classic experience web parts.

The following URL shows some of the modern web part equivalents of classic web parts. Please note that these are not a 1:1 matching, instead they have similar functionalities.

Click here to visit “Classic and modern web part experiences” by Microsoft

Get folder and files recursively in SharePoint using REST call

There was a simple requirement I came across for which a page should list all the files and folders in a SharePoint document library.

I came up with a solution using ODATA call. Following is the REST call I made to get the list of all folder and files.

/_api/web/Lists/GetByTitle(‘Documents’)/Items?$select=FileLeafRef,FileRef&$orderby=FileRef asc

Following is the code which quickly prints them out in a table. Just add this code to a script editor web-part.
Please make sure the URL is updated based on your site URL.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
    $.ajax({
        url: "<site url>/_api/web/Lists/GetByTitle('Documents')/Items?$select=FileLeafRef,FileRef&$orderby=FileRef asc",
        type: "GET",
        headers: {
            "Accept": "application/json;odata=verbose"
        },
        success: function (data, textStatus, xhr)
        {
            $.each(data.d.results, function (index, item)
            {
                // alert("The items in list are : " + item.FileRef);
                $("#table1 tbody").append("<tr><td>" + item.FileRef + "</td></tr>");
            })
        },
        error: function r(xhr, textStatus, errorThrown)
        {
            alert("error:" + JSON.stringify(xhr));
        }
    });
</script>

<table id="table1">
    <tbody></tbody>
</table>

Enable tree view in current navigation within SharePoint

Sometime we need to enable tree view in current navigation to help navigate within document libraries.

Traditional Way:

Site Settings -> Look and Feel: Navigation Elements -> Check ‘Enable Tree View’

Programmatic way using PnP Powershell:

try {
    $web = Get-PnPWeb -Includes TreeViewEnabled
    Write-Host "Setting options to enable tree view..."
    $web.TreeViewEnabled = $true        
    $web.Update()
    Invoke-PnPQuery
    Write-Host "Completed."
}
catch {
    $ErrorMessage = $_.Exception.Message
    Write-Host "Error enabling tree view. $ErrorMessage"
}

Disable ‘Allow items from this site to be downloaded to offline clients’ in SharePoint

Sometime we need to disable the “Sync” button in SharePoint document libraries and that can be done by the following methods.

Traditional Way:

Site Settings -> Search: Search and offline availability -> Set ‘Allow items from this site to be downloaded to offline clients?’ to “No”

Programmatic way using PnP Powershell:

try {
    $web = Get-PnPWeb -Includes ExcludeFromOfflineClient
    Write-Host "Setting options to disable 'Allow items from this site to be downloaded to offline clients'..."
    $web.ExcludeFromOfflineClient = $true        
    $web.Update()
    Invoke-PnPQuery
    Write-Host "Completed."
}
catch {
    $ErrorMessage = $_.Exception.Message
    Write-Host "Error disabling offline clients. $ErrorMessage"
}

Sharepoint disable drag and drop

In some scenarios we might need to disabled drag and drop in SharePoint sites.

The following code works when we need to disable a page with one document view.

Add the html code in content editor web part where the document view is there.

<style type="text/css">
    /*-- Hide Drag & Drop --*/    
    caption.ms-dragDropAttract {
        caption-side: bottom;
        display: none !important;
    }
</style>

<script type="text/javascript">
    /*-- Stop Drag & Drop --*/
    ExecuteOrDelayUntilScriptLoaded(function() {
        g_uploadType = DragDropMode.NOTSUPPORTED;
        SPDragDropManager.DragDropMode = DragDropMode.NOTSUPPORTED;
        SPDragDropManager.DargDropMode.style.display = "none";
    }, "DragDrop.js");
</script>

For pages with multiple document libraries when you want to target a specific library prepend the id of the web part div and an underscore e.g. WebPartWPQ4_

#WebPartWPQ4_ms-dnd-dropbox{ display: none !important; }

Source: https://sharepoint.stackexchange.com/questions/82805/how-can-i-disable-the-document-library-drag-and-drop-function