Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

Hide/Disable Web search external images in SharePoint Online

SharePoint Online offers powerful web parts and features that enhance the visual appeal of your sites, including the ability to search for external images on the web while using web parts like Image, Hero, Image Gallery, Quick links, etc. While this feature can be valuable in various contexts, there are scenarios where organizations prefer to disable or hide the option to search for external images especially when they have created organization assets libraries in the SharePoint tenant.

In this blog post, we’ll explore how to hide/disable the “Web search” feature in SharePoint using SharePoint Online PowerShell, PnP PowerShell and CLI for Microsoft 365.

Using SharePoint Online PowerShell

Use below SharePoint Online PowerShell script to disable or enable external image “Web Search” feature in SharePoint Online tenant:

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Disable external image "Web Search" feature in SharePoint
Set-SPOTenant -FilePickerExternalImageSearchEnabled $false

# Enable external image "Web Search" feature in SharePoint
# Set-SPOTenant -FilePickerExternalImageSearchEnabled $true

# Disconnect SharePoint online connection
Disconnect-SPOService

Using PnP PowerShell

You can use below PnP PowerShell script to hide/disable external image “Web Search” feature in SharePoint Online:

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $adminCenterUrl -Interactive

# Disable external image "Web Search" feature in SharePoint
Set-PnPTenant -FilePickerExternalImageSearchEnabled $false

# Enable external image "Web Search" feature in SharePoint
# Set-PnPTenant -FilePickerExternalImageSearchEnabled $true

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to remove/disable external image “Web Search” feature in SharePoint Online tenant:

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
m365 login
}

# Disable external image "Web Search" feature in SharePoint
m365 spo tenant settings set --FilePickerExternalImageSearchEnabled false

# Enable external image "Web Search" feature in SharePoint
# m365 spo tenant settings set --FilePickerExternalImageSearchEnabled true

# Disconnect SharePoint online connection
m365 logout

Conclusion

Disabling or hiding the web search for external images in SharePoint Online is a strategic choice for organizations that prioritize content security, brand consistency and compliance. By following the methods outlined in this blog post, you can tailor your SharePoint environment to align with your organization’s policies and enhance the overall governance of your digital assets.

Learn more

Create an Organization Assets Library in SharePoint Online

In the dynamic world of business collaboration, organizing and sharing digital assets efficiently is a key factor for success. SharePoint Online provides a robust solution for managing organizational assets through the creation of an “Organization Assets Library.” In this blog post, we’ll explore what an Organization Assets Library is and provide a step-by-step guide on how to create organization asset libraries in SharePoint Online.

What is an Organization Assets Library in SharePoint?

An organization assets library in SharePoint is a centralized repository for storing and managing digital assets like images such as company branding photos & logos and office templates like word, excel & PowerPoint documents that are commonly used across the organization. It provides a structured way to organize, access, and share these assets, ensuring consistency in branding (logos, style guides, templates) and seamless collaboration.

Types of Organization Assets Library

You can create two types of Organization Assets libraries in SharePoint Online:

  • Organization Asset Library for Images (ImageDocumentLibrary): Document library for images like branding images, company logos, etc. These images will be available under “Your organization” option when user opens the file picker while adding images in SharePoint web parts and pages.
  • Organization Asset Library for Office Templates (OfficeTemplateLibrary): Document library for office templates like word, excel and PowerPoint. These templates will be available when user creates a new office document from Office Apps. Follow this article for creating office templates.

How to Create an Organization Assets Library in SharePoint Online?

Step 1: Create a SharePoint Online site

You can use an existing site or create a new site for storing organization assets. The site can be of any type (communication site or team site). However, I will recommend you to create a new/blank communication site for hosting organization asset libraries. Follow this guide for creating a new SharePoint site: Create a site in SharePoint.

Step 2: Grant permissions on SharePoint Online site

Grant following permissions on the newly created SharePoint communication site:

  1. Owners: Add users who should be able to upload files to asset libraries as well as manage permissions of the site.
  2. Members: Add users who should be able to upload files to asset libraries.
  3. Visitors: Add Everyone except external users group so that all users in tenant can see assets.
Step 3: Create Document libraries and upload assets

Create new document libraries to store the organization assets by following this guide: Create a document library in SharePoint. After creating document libraries, upload the images or office templates to your document libraries.

Step 4: Register Document library as organization asset library

First of all, download the latest version of SharePoint Online Management Shell. Then you can run SharePoint Online PowerShell script like below from SharePoint Online Management Shell to register a document library as an organization asset library for images (you can use $orgAssetType = "OfficeTemplateLibrary" for office templates asset library):

# URL of SharePoint document library
$libraryUrl = "https://contoso.sharepoint.com/sites/OrgAssets/Images"

# Type of Organization asset library - ImageDocumentLibrary or OfficeTemplateLibrary
$orgAssetType = "ImageDocumentLibrary"

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Register document library as an organization asset library
Add-SPOOrgAssetsLibrary -LibraryURL $libraryUrl -OrgAssetType $orgAssetType

# Disconnect SharePoint online connection
Disconnect-SPOService

You’ll be prompted to enable a content delivery network (CDN) while adding an organization asset library, type Y (Yes) or A (Yes to All) and press Enter.

If you get an error – Add-SPOOrgAssetsLibrary : This library is not on the site that contains other organization asset libraries while running above PowerShell script, that means some other organization asset libraries are already available in your Microsoft 365 SharePoint tenant. In that case, try this:

1. Firstly, check if you have any existing organization asset libraries in your Microsoft 365 tenant using this command:

Get-SPOOrgAssetsLibrary

2. Create a new document library on same SharePoint site where your existing organization asset libraries are created.

3. Run PowerShell script given in step 4 to register the newly created document library as an organization asset library.

Notes

  1. You can create up to 30 organization asset libraries for a single tenant / organization.
  2. All organization asset libraries must be on the same SharePoint site.
  3. Only document libraries (not folders) can be set as organization asset libraries.
  4. It may take up to 24 hours for the organization assets library to appear in the desktop office apps.
  5. Users need at least read permissions on the SharePoint root site for the organization assets library to appear in the desktop office apps.

How to Remove an Organization Assets Library from SharePoint Online?

If you want to remove/unregister an existing organization asset library from your SharePoint tenant, you can use below SharePoint Online PowerShell script:

# URL of SharePoint document library
$libraryUrl = "https://contoso.sharepoint.com/sites/OrgAssets/Images"

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Remove/unregister an organization asset library in SharePoint tenant
Remove-SPOOrgAssetsLibrary -LibraryUrl $libraryUrl

# Disconnect SharePoint online connection
Disconnect-SPOService

In conclusion, implementing an organization assets library in SharePoint Online can significantly enhance the management and utilization of essential resources within your organization. By centralizing assets, maintaining consistency, and enabling seamless collaboration, SharePoint empowers teams to work more efficiently and effectively.

Learn more

SharePoint Online: All you need to know about Commenting in Lists

Microsoft recently introduced a new feature of commenting in SharePoint Online lists and Microsoft lists. Using this feature users will be able to add and delete comments on list items. Users can view all comments on a list item and filter between views that show comments or activity related to an item in details pane.

Microsoft has started rolling out this feature to all SharePoint Online tenants in December 2020 release, see Roadmap.

Where can you find Comments options?

Comments options are currently located at below three places in SharePoint Online/Microsoft lists:

List view

Users can see which list items have comments when they access the SharePoint Online list view or Microsoft list home page. Comments option will be shown on command bar when you select a list item as well as at the right hand side of Title column. When you hover over on comments icon it will show you the count of comments added to the list item.

New Comments in SharePoint list view
Comments options in List view
Display/Edit form

By default, users will see a new comments pane alongside the list item form when they access a list. Users can toggle the comment pane visibility by clicking the comments icon. When you hide comments, the pane does not collapse. The comments pane will be closed by default for lists customized by Power Apps.

New Comments in SharePoint list display form
Comments options on Display form
Details Pane

Users can see the Comments and All activity related to list item on details pane. Users can filter views that show comments or activity by using the dropdown under “More details” section.

New Comments options in Details pane in SharePoint Online list
Comments options in Details pane

Permission Considerations

Comments follow the permission settings inherent in SharePoint Online and Microsoft Lists.

  • Users with read-only permission can only view comments.
  • Those with list edit permission can make comments as well as delete comments; editing comments is currently not possible. 

Where the Comments will be stored?

Comments are stored in the schema for each list, which is based on the SharePoint storage platform.

Working with SharePoint REST APIs

As comments are stored within the list schema itself and not with list items, it is not possible to fetch comments using  $select with /items endpoint. However, you can get the list item comments using below endpoint:

https://<tenant>.sharepoint.com/sites/<site>/_api/web/lists/getbytitle('<list-name>')/GetItemById(<item-id>)/Comments()

//OR

https://<tenant>.sharepoint.com/sites/<site>/_api/web/lists/getbytitle('<list-name>')/items(<item-id>)/Comments()

For more information on working with comments using SharePoint REST APIs, check:

Working with JSON Formatting

Currently it is not possible to get the actual list item comments value using JSON formatting. But, you can get the count of comments added to list item using [$_CommentCount] which is an internal name of SharePoint list column that returns the count of list item comments.

Check how you can get comments count and show it in SharePoint list view at: Working with SharePoint Online/Microsoft List Comments using JSON Formatting.

Current Limitations

  • Editing comments is currently not possible.
  • Any user can delete the list item comments. Currently there is no way to disable deletion of comments.
  • Maximum characters limit in list comments: 2000 characters
  • Classic lists that are not yet built to show up in modern user interfaces, like Task lists, will not have this commenting feature.
  • Commenting on lists in Teams is not available with this release.
  • Comments are not indexed by Search.

Enable/Disable Comments

Currently it is not possible to disable commenting at the site or list level. Microsoft is working on the new feature which will allow users to enable/disable the comments for individual SharePoint lists. However, Admins can enable/disable this feature at the organization level by changing the CommentsOnListItemsDisabled parameter in the Set-SPOTenant PowerShell cmdlet:

Read more about how to enable/disable the commenting in SharePoint Online/Microsoft Lists at: How to Enable/Disable the commenting in SharePoint Online/Microsoft Lists.

What’s Next?

  • Currently it is not possible to disable commenting at the site or list level. Microsoft is currently working on this feature update, more information at: Enable/Disable the comments for a SharePoint Online/Microsoft List.
  • @mentions in comments:
    • Get a colleague’s attention to an item in a list by @mentioning them within list comments. That person will receive a notification and a link that takes them directly back to the item, to review the comment and take the requested action.

I hope you liked this blog. Give your valuable feedback & suggestions in the comments section below and share this blog with others.

How to Enable or Disable Auto News Digest in SharePoint Online

In today’s fast-paced work environment, staying up to date with the latest news and updates within an organization is crucial. SharePoint Online offers a powerful feature called Auto News Digest, which automatically aggregates the latest news posts from various SharePoint sites and Organization news sites that are relevant to users and sends an automated email to users.

SharePoint uses Microsoft Graph to determine if the news post is relevant for a user or not. SharePoint sends one email digest per week. By leveraging this feature, users can stay informed without having to manually visit each site individually, saving time and ensuring they don’t miss out on important updates.

In some cases, organizations that already have a high volume of emails may choose to disable SharePoint Auto News Digest feature to minimize the number of additional emails being sent to users. You can use any one of the approaches given below for enabling or disabling auto news digest feature in SharePoint online for all users at tenant level.

Using SharePoint Online PowerShell

Use below SharePoint Online PowerShell script to enable or disable the SharePoint auto news digest feature in SharePoint online at tenant level:

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Enable Auto News Digest in SharePoint Online
Set-SPOTenant -EnableAutoNewsDigest $true

# Disable Auto News Digest in SharePoint Online
Set-SPOTenant -EnableAutoNewsDigest $false

# Disconnect SharePoint online connection
Disconnect-SPOService

Using PnP PowerShell

You can use below PnP PowerShell script for enabling or disabling the SharePoint auto news digest feature in SharePoint online for all users at tenant level: 

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint admin center site URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $adminCenterUrl -Interactive

# Enable Auto News Digest in SharePoint Online
Set-PnPTenant -EnableAutoNewsDigest $true

# Disable Auto News Digest in SharePoint Online
Set-PnPTenant -EnableAutoNewsDigest $false

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Conclusion

SharePoint Auto News Digest is a valuable feature that helps streamline information delivery within organizations. By enabling this feature, SharePoint can automatically compile and deliver news and updates from various SharePoint sites directly to users’ inboxes. Disabling Auto News Digest is also straightforward, allowing organizations to customize their SharePoint experience based on their specific requirements. SharePoint Online PowerShell and PnP PowerShell scripts provide convenient methods to enable or disable Auto News Digest effortlessly, empowering administrators to optimize their SharePoint environment for efficient information sharing.

Learn more

Enable or Disable the Social Bar (Like, Views, Save for later) for individual SharePoint sites

In my previous blog, we saw how to enable or disable the Social Bar (Like, Views, Save for later) in SharePoint Online at tenant level using SharePoint Online PowerShell, PnP PowerShell and CLI for Microsoft 365. In this blog we will explore how to enable or disable the Social Bar for individual SharePoint online site collections.

You can use any one of the approaches given below for enabling or disabling the Social Bar (Like, No. of Comments, Views, Save for later) for individual SharePoint online sites.

Using SharePoint Online PowerShell

Use below SharePoint Online PowerShell script to enable or disable the social bar from site pages for specific SharePoint online modern experience site:

# SharePoint online admin center URL
$adminCenterUrl = Read-Host -Prompt "Enter your SharePoint online admin center URL (e.g https://contoso-admin.sharepoint.com/)"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/work)"

# Disable the social bar from SharePoint online site pages
Set-SPOSite -Identity $siteUrl -SocialBarOnSitePagesDisabled $true

# Enable the social bar on SharePoint online site pages
Set-SPOSite -Identity $siteUrl -SocialBarOnSitePagesDisabled $false

# Disconnect SharePoint online connection
Disconnect-SPOService

Using PnP PowerShell

You can use below PnP PowerShell script to show or hide the social bar from SharePoint online modern experience site pages for individual SharePoint site:

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/work)"

# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive

# Hide the social bar from SharePoint online modern site pages
Set-PnPSite -SocialBarOnSitePagesDisabled $true

# Show the social bar on SharePoint online modern site pages
Set-PnPSite -SocialBarOnSitePagesDisabled $false

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Using CLI for Microsoft 365

Use below CLI for Microsoft script to show or hide the social bar from SharePoint online modern experience site pages for individual SharePoint site:

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/work)"

# Connect to SharePoint online tenant
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Hide the social bar from SharePoint online modern site pages
m365 spo site set --url $siteUrl --socialBarOnSitePagesDisabled true

# Show the social bar on SharePoint online modern site pages
m365 spo site set --url $siteUrl --socialBarOnSitePagesDisabled false

# Disconnect SharePoint online connection
m365 logout

Conclusion

By using the PowerShell scripts given in this blog post, you can enable or disable social bar features from SharePoint online modern site pages for specific SharePoint online sites.

Learn more

Enable or Disable the Social Bar (Like, Views, Save for later) in SharePoint at tenant level

SharePoint Online provides various social features in modern experience SharePoint sites. One of the features available for SharePoint site pages is the social bar (Like, No. of Comments, Views, Save for later), which is situated at the bottom of site pages. Social bar allows users to engage with page content by liking and saving pages for later reference. Social bar also shows the number of page views and comments on modern site pages.

However, organizations may have specific requirements that necessitate enabling or disabling the social bar on SharePoint site pages. Unfortunately, there are no settings available for enabling/disabling social bar using SharePoint user interface. In this blog post, we will explore how to achieve this at SharePoint tenant level using SharePoint Online PowerShell, PnP PowerShell and CLI for Microsoft 365 scripts.

Using SharePoint Online PowerShell

Use below SharePoint Online PowerShell script to enable or disable the social bar from site pages for all SharePoint sites in the tenant:

# SharePoint online admin center URL
$adminCenterUrl = "https://contoso-admin.sharepoint.com/"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Disable the social bar from SharePoint online site pages
Set-SPOTenant -SocialBarOnSitePagesDisabled $true

# Enable the social bar on SharePoint online site pages
Set-SPOTenant -SocialBarOnSitePagesDisabled $false

Using PnP PowerShell

You can use below PnP PowerShell script to show or hide the social bar from SharePoint online modern experience site pages:

# SharePoint online admin center URL
$adminCenterUrl = "https://contoso-admin.sharepoint.com/"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $adminCenterUrl -Interactive

# Show the social bar on SharePoint online modern site pages
Set-PnPTenant -SocialBarOnSitePagesDisabled $false

# Hide the social bar from SharePoint online modern site pages
Set-PnPTenant -SocialBarOnSitePagesDisabled $true

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to enable or disable the Social Bar (like, No. of comments, views, Save for later) in SharePoint online at tenant level:

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Disable the social bar from SharePoint online site pages
m365 spo tenant settings set --SocialBarOnSitePagesDisabled true

# Enable the social bar on SharePoint online site pages
m365 spo tenant settings set --SocialBarOnSitePagesDisabled false

Conclusion

Enabling or disabling the social bar on site pages in SharePoint Online can be achieved using SharePoint Online PowerShell, PnP PowerShell or CLI for Microsoft 365 scripts. By following the steps outlined in this blog post, you can customize the user experience and align it with your organization’s specific requirements. Whether you want to encourage user engagement or disable social features for certain scenarios, these PowerShell scripts provide the flexibility to control the social bar’s presence on SharePoint online modern site pages.

Learn more

Enable or Disable the Return to Classic SharePoint link in SharePoint Online

SharePoint Online provides a modernized and responsive user interface that offers improved collaboration, customization, and integration capabilities. It provides a clean and intuitive design, responsive layouts, and enhanced mobile support. Modern SharePoint sites include modern lists and libraries, modern web parts, and modern pages.

On modern SharePoint list and library pages, there’s a link in the lower left of the page below quick launch (left navigation) that says Return to classic SharePoint. This link allows users who are working in the SharePoint modern experience to switch the current list or document library to classic experience. On the classic page, there’s a corresponding link that says Exit classic experience which reverts the current list or document library back to modern experience.

You may want to hide Return to classic SharePoint link from list and library pages to promote the adoption & utilization of the modern experience and have consistent modern user experience across the SharePoint site.

Luckily, as a tenant administrator you have control to show or hide these links from SharePoint online modern experience using one of the ways shown below:

Using SharePoint Online PowerShell

Use below SharePoint Online PowerShell script to enable or disable the Return to classic SharePoint and Exit classic experience links from SharePoint list and document library pages:

# SharePoint online admin center URL
$adminCenterUrl = "https://contoso-admin.sharepoint.com/"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Enable Return to classic SharePoint and Exit classic experience links
Set-SPOTenant -DisableBackToClassic $false

# Disable Return to classic SharePoint and Exit classic experience links
Set-SPOTenant -DisableBackToClassic $true

Using PnP PowerShell

You can use below PnP PowerShell script to show or hide the “Return to classic SharePoint” and “Exit classic experience” links from SharePoint online modern experience list and document library pages:

# SharePoint online admin center URL
$adminCenterUrl = "https://contoso-admin.sharepoint.com/"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $adminCenterUrl -Interactive

# Show Return to classic SharePoint and Exit classic experience links
Set-PnPTenant -DisableBackToClassic $false

# Hide Return to classic SharePoint and Exit classic experience links
Set-PnPTenant -DisableBackToClassic $true

Conclusion

Enabling or disabling the “Return to Classic SharePoint” and “Exit classic experience” links in SharePoint Online can be accomplished using SharePoint Online PowerShell or PnP PowerShell scripts. By following the steps outlined in this blog post, you can manage the user experience and tailor it to your organization’s specific requirements. Whether you embrace the modern SharePoint experience or occasionally need access to classic features, these PowerShell scripts provide the flexibility to adapt SharePoint Online to your needs.

Learn more

Allow use of custom scripts in SharePoint Online using PowerShell

SharePoint online is a powerful platform that allows users to create and manage websites and content, collaborate with others, and more. However, SharePoint out-of-the-box features may not always meet the specific needs of your organization.

Fortunately, SharePoint online allows the use of custom scripts, which can be used to enhance the platform’s functionality and customize it to your specific needs.

When you allow the use of custom scripts in SharePoint online sites, users gain access to a wide range of features and functionalities. Here are some of the key capabilities that become available:

  • Web Parts: Users can use classic experience web parts like Script Editor, Content Editor (and lot more) using which they can create custom web parts using client-side scripting languages like JavaScript or TypeScript.
  • Use of Save Site as Template, Save document library as template, etc. features in SharePoint.
  • Use of Solution Gallery, Theme Gallery, Sandbox solutions, HTML Field Security, etc. settings in SharePoint sites.
  • Uploading files types that are blocked by default like .asmx .ascx .aspx .htc .jar .master .swf .xap .xsf

Let’s see how you can allow or prevent use of custom scripts in SharePoint Online sites using different PowerShell tools:

Using SharePoint Online PowerShell

Use below SharePoint Online PowerShell script to check if custom scripts are enabled or disabled for a SharePoint online site and then to allow use of custom scripts for specified SharePoint online site:

# SharePoint online admin center URL
$adminCenterUrl = "https://contoso-admin.sharepoint.com/"

# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Connect to SharePoint online admin center
Connect-SPOService -Url $adminCenterUrl

# Allow custom scripts on SharePoint online site
Set-SPOSite $siteUrl -DenyAddAndCustomizePages 0

# Verify that custom scripts are enabled on SharePoint online site
Get-SPOSite $siteUrl | select DenyAddAndCustomizePages

Using PnP PowerShell

You can use below PnP PowerShell script to allow or prevent use of custom scripts in SharePoint online site:

# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive

# Allow custom scripts on SharePoint online site
Set-PnPSite -NoScriptSite $false

# Prevent custom scripts on SharePoint online site
Set-PnPSite -NoScriptSite $true

Using CLI For Microsoft 365

Use below CLI for Microsoft 365 script to allow use of custom scripts in SharePoint online site collection:

# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Connect to SharePoint online tenant
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Allow custom scripts on SharePoint online site collection
m365 spo site set --url $siteUrl --noScriptSite $false

Conclusion

Enabling custom script support for SharePoint online sites can enhance the platform’s functionality and enable users to customize site to their specific needs. However, it’s important to carefully consider the potential security risks before enabling this feature, check: security considerations of allowing custom scripts in SharePoint.

Learn more

Delete custom site scripts in SharePoint online

In SharePoint online, you can use Site templates (previously known as “Site designs”) and Site scripts to provide reusable site columns, content types, lists, themes, site navigation layouts, or custom actions so that your users can quickly build new SharePoint sites with the features they need. SharePoint custom site scripts can help you to add custom branding, theming, or automation like setting a site logo, activating a site feature, etc. to your SharePoint online site.

However, over time, these custom site scripts can become outdated or unnecessary and ends up just hanging around in your SharePoint tenant for a long time even though you no longer need them. In this blog, we will discuss how to delete the custom SharePoint site scripts using PowerShell “scripts” (pun intended).

Using SharePoint Online PowerShell

You can run below SharePoint online PowerShell script from SharePoint Online Management Shell to delete the custom site scripts in your tenant:

# SharePoint online admin site URL
$siteUrl = "https://contoso-admin.sharepoint.com/"

# Connect to SharePoint online admin center
Connect-SPOService -Url $siteUrl

# Get all site scripts from the current tenant
$siteScripts = Get-SPOSiteScript

# List of custom site scripts to exclude from deletion
$keepThese = "Base Site Settings", "English Region", "Standard Site Columns", "Standard Libraries"
$siteScripts = $siteScripts | Where-Object { -not ($keepThese -contains $_.Title)}

if ($siteScripts.Count -eq 0) { break }

$siteScripts | Format-Table Title, SiteScriptIds, Description

Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $siteScripts.Count

foreach ($siteScript in $siteScripts)
{
    $progress++
    Write-Host $progress / $total":" $siteScript.Title

    # Delete custom site script
    Remove-SPOSiteScript -Identity $siteScript.Id
}

# Disconnect SharePoint online connection
Disconnect-SPOService

Using PnP PowerShell

Use below PnP PowerShell script to delete the custom site scripts from SharePoint online tenant:

# SharePoint online admin site URL
$siteUrl = "https://contoso-admin.sharepoint.com/"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $siteUrl -Interactive

# Get all site scripts from the current tenant
$siteScripts = Get-PnPSiteScript

# List of custom site scripts to exclude from deletion
$keepThese = "Base Site Settings", "English Region", "Standard Site Columns", "Standard Libraries"
$siteScripts = $siteScripts | Where-Object { -not ($keepThese -contains $_.Title)}

if ($siteScripts.Count -eq 0) { break }

$siteScripts | Format-Table Title, SiteScriptIds, Description

Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $siteScripts.Count

foreach ($siteScript in $siteScripts)
{
    $progress++
    Write-Host $progress / $total":" $siteScript.Title

    # Delete custom site script
    Remove-PnPSiteScript -Identity $siteScript.Id
}

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to remove custom SharePoint site scripts from your tenant:

# Get credentials to connect to SharePoint online tenant
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Get all site scripts from the current tenant
$siteScripts = m365 spo sitescript list | ConvertFrom-Json

# List of custom site scripts to exclude from deletion
$keepThese = "Base Site Settings", "English Region", "Standard Site Columns", "Standard Libraries"
$siteScripts = $siteScripts | Where-Object { -not ($keepThese -contains $_.Title)}

if ($siteScripts.Count -eq 0) { break }

$siteScripts | Format-Table Title, SiteScriptIds, Description

Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $siteScripts.Count

foreach ($siteScript in $siteScripts)
{
    $progress++
    Write-Host $progress / $total":" $siteScript.Title

    # Delete custom site script
    m365 spo sitescript remove --id $siteScript.Id
}

# Disconnect SharePoint online connection
m365 logout

These PowerShell scripts are also available on PnP Script Samples site at: Delete custom SharePoint site scripts.

Learn more

Set up a home site in SharePoint Online

Microsoft is currently rolling out SharePoint app bar and Global navigation to SharePoint online tenants. By default the home icon in app bar is linked to the SharePoint start page. To change this behavior, you need to enable the global navigation. Enabling and customizing global navigation in SharePoint requires a home site.

SharePoint online home site is also required to use Microsoft Viva connections in Microsoft Teams desktop client.

So, if you are planning to customize the global navigation or use Microsoft Viva connections in Microsoft Teams, first you have to set up a home site for your SharePoint online tenant. Home site is a SharePoint site that you create and set as the top landing page for all users in your intranet. You can set only one SharePoint site as a home site which must be a communication site.

Steps to set a site as your home site

  1. Create a communication site to set it as the home site or use existing communication site.
  2. Customize the communication site by adding navigation, header, footer, site logo, news, events and other web parts as per your requirements and brand.
  3. Use PowerShell commands to set a communication site as the home site.

Use PowerShell to set a communication site as the home site

After you create and customize the communication site that you want to use as your home site, you need to run a PowerShell commands to set it as your home site. To run this commands, you must be a global admin or SharePoint admin in your Microsoft 365 tenant.

Using SharePoint Online PowerShell

1. Download the latest version of SharePoint Online Management Shell.

2. Connect to SharePoint admin site as a global admin or SharePoint admin using below command:

Connect-SPOService -Url https://<tenant>-admin.sharepoint.com

3. Run below command to set a communication site as the home site:

Set-SPOHomeSite -HomeSiteUrl https://<tenant>.sharepoint.com/sites/<communicationsite>
Using PnP PowerShell

You can use PnP PowerShell Set-PnPHomeSite command to set the home site for your SharePoint tenant.

Connect-PnPOnline -Url https://<tenant>-admin.sharepoint.com/ -Interactive
Set-PnPHomeSite -HomeSiteUrl "https://<tenant>.sharepoint.com/sites/<communicationsite>"
Using CLI for Microsoft 365

You can use CLI for Microsoft 365 spo homesite set command to set the specified communication site as the Home Site.

m365 login
m365 spo homesite set --siteUrl https://<tenant>.sharepoint.com/sites/<communicationsite>

Points to remember

  • Only one communication site can be set as the home site.
  • Search scope for the site will be changed to tenant-wide search.
  • The site will be automatically set up as an organization news site.
  • The first time you set up a home site, it might take up to several minutes for the changes to take effect.
  • If you run the above command again to switch your home site to a different site, it might take up to 2 hours.
  • Home site can be registered as a hub site, but it can’t be associated with a hub.

Unregister a home site from your tenant

If you have registered a site as a home site in your tenant previously and now you don’t want to have any home site in your tenant, you need to run the following PowerShell command with administrator privileges:

Remove-SPOHomeSite

This removes the current SharePoint Online Home Site setting. Note that you do not need to specify the URL of your home site.

Learn more

How to Enable/Disable the commenting in SharePoint Online/Microsoft Lists

In my previous blog about Commenting in SharePoint Online and Microsoft lists, I explained where you can find the comments options, what are the permission considerations, working with commenting using SharePoint REST APIs and JSON formatting, etc. In this blog I will explain how you can enable/disable the commenting in SharePoint Online/Microsoft Lists.

Commenting in lists is a great feature which will help many organizations. However, it’s possible that some organizations may want to disable this feature as they already have some mechanism in place for commenting, for example approvals system as mentioned here.

Currently it is not possible to disable commenting at the SharePoint site or list level (possible as of June 2021). Microsoft is working on the new feature which will allow users to enable/disable the comments for individual SharePoint lists.

However, Admins can enable/disable this feature at the organization level by changing the CommentsOnListItemsDisabled parameter in the Set-SPOTenant PowerShell cmdlet:

# To disable comments on list items
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com/ 
Set-SPOTenant -CommentsOnListItemsDisabled $true

# To enable comments on list items
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com/ 
Set-SPOTenant -CommentsOnListItemsDisabled $false

Replace <tenant> with the name of your Microsoft 365 tenant.

Using PnP PowerShell

You can also use PnP PowerShell to enable or disable commenting in SharePoint Online/Microsoft Lists at tenant level:

# Connect to SharePoint online admin center
Connect-PnPOnline -Url https://<tenant>-admin.sharepoint.com/ -Interactive

# To disable comments on list items
Set-PnPTenant -CommentsOnListItemsDisabled $true

# To enable comments on list items
Set-PnPTenant -CommentsOnListItemsDisabled $false

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to enable or disable commenting in SharePoint Online/Microsoft Lists at tenant level:

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# To disable comments on list items
m365 spo tenant settings set --CommentsOnListItemsDisabled true

# To enable comments on list items
m365 spo tenant settings set --CommentsOnListItemsDisabled false

Note: You must be a SharePoint Administrator or Global Administrator in your tenant to enable/disable this feature using PowerShell.

I hope you liked this blog. Give your valuable feedback & suggestions in the comments section below and share this blog with others.

See also

❌
❌