Vue normale

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

How to Hide a SharePoint List or Library from the UI?

SharePoint provides powerful collaboration features to users including lists and libraries, and while transparency is crucial, there are instances where hiding a list or library becomes essential for optimizing user experiences and/or maintaining data integrity. Example: Power Apps often relies on SharePoint lists as data sources. However, not all lists are meant for end users to view directly. By hiding lists or libraries from SharePoint UI, you can prevent end users from editing the data directly from SharePoint lists.

In this blog post, we’ll explore how to hide a SharePoint list or document library using PnP PowerShell & CLI for Microsoft 365 and view all hidden lists/libraries in SharePoint site using PnP PowerShell & CLI for Microsoft 365.

Hiding a SharePoint List or Library using PnP PowerShell

You can use below PnP PowerShell script to hide a SharePoint online list or document library from SharePoint UI (Site Contents page):

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

# Display name of SharePoint online list or document library
$listName = Read-Host -Prompt "Enter the display name of your SharePoint list or library (e.g My List)"

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

# Hide SharePoint online list from UI
Set-PnPList -Identity $listName -Hidden $true

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Hide a SharePoint List or Library using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to hide a SharePoint list or document library from SharePoint UI:

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

# Display name of SharePoint online list or document library
$listName = Read-Host -Prompt "Enter the display name of your SharePoint list or library (e.g My List)"

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

# Hide SharePoint online list or library from UI (Site Contents)
m365 spo list set --webUrl $siteUrl --title $listName --hidden true

# Disconnect SharePoint online connection
m365 logout

View hidden lists/libraries in SharePoint site using PnP PowerShell

You can use below PnP PowerShell script to view all hidden lists and libraries in the given SharePoint site:

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

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

# View all hidden lists/libraries in a SharePoint online site
Get-PnPList | Where-Object {$_.Hidden -eq $true}

# Disconnect SharePoint online connection
Disconnect-PnPOnline

View hidden lists/libraries in SharePoint site using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to view all hidden lists and document libraries in the given SharePoint online site:

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

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

# Hide SharePoint online list or library from UI (Site Contents)
m365 spo list list --webUrl $siteUrl --properties "Id,Title,Url" --filter "Hidden eq true" | ConvertFrom-Json

# Disconnect SharePoint online connection
m365 logout

Learn more

Update SharePoint Page Banner Image using PnP PowerShell

Using pages in SharePoint is a great way to share information or any news/announcement in your organization to SharePoint site users. SharePoint site pages can be improved by utilizing banner images in the page title area. Adding banner images to the page title area not only makes the page more visually appealing but also helps to convey the page’s purpose to the user more quickly and effectively.

In this blog post, we will see how to change the SharePoint Page Banner Image using PnP PowerShell.

First of all upload a high quality image in one of the document libraries in your SharePoint site. SharePoint site page banner images in title area look best when they are landscape or 16:9 or greater in aspect ratio, and when they are at least 1 MB in size. Check this Microsoft official documentation for recommended specifications for banner images: Image sizing and scaling in SharePoint modern pages

Then you can use below PnP PowerShell script to update the banner image at the top of the SharePoint online modern page:


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

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

# Update SharePoint site page banner image
Set-PnPPage -Identity "Open-Door-Policy" -HeaderType Custom -ServerRelativeImageUrl "/sites/wlive/SiteAssets/work-remotely.jpeg"

Once you run above script successfully, you will find that banner image for your SharePoint site page is updated successfully:

Update SharePoint online modern page banner image in page title area using PnP PowerShell
Update SharePoint Page Banner Image using PnP PowerShell

Learn more

How to find the Internal name of columns in SharePoint Online?

The internal name of a SharePoint column is a unique name that is automatically generated by SharePoint when a column is created. It is used by SharePoint internally to reference and retrieve the value of a particular column associated with an item or document. The internal name is generated based on the display name you provide but all special characters and spaces will be replaced with Unicode’s by SharePoint. Internal name is generated only once while creating a new column and it cannot be changed even if you change the display name of SharePoint column.

The internal name is not visible to users in the SharePoint user interface by default, but it is commonly used in various scenarios, such as in SharePoint REST APIs, Power Automate flow expressions, Power Apps formulas, PowerShell, etc. to interact with column data programmatically.

Where are Internal names of SharePoint columns used?

  1. Custom Scripts: When creating custom scripts, such as JavaScript or PowerShell, the internal names of columns are required to reference and manipulate the values of the columns while interacting with SharePoint data.
  2. Workflows: In SharePoint Designer workflows or Microsoft Power Automate (formerly known as Microsoft Flow), the internal names of columns are used to reference the values of the columns as inputs or outputs in the workflow actions and in expressions.
  3. Custom Solutions: When building custom solutions, such as SharePoint apps, SharePoint framework (SPFx) web parts, or custom code, the internal names of columns are required to interact with the columns programmatically.
  4. Power Apps: Few of the Power Apps functions like ShowColumns, SortByColumns, etc. requires using internal names of SharePoint columns in formula.
  5. JSON Formatting: Internal name of SharePoint column is required in JSON formatting to reference the column value with [$InternalNameOfColumn] syntax.

How to find the Internal name of a SharePoint column?

Using Modern experience list view

You can use sorting or filtering options from SharePoint online modern experience list view to find the internal name of a SharePoint column. Sort by and Filter by options are supported by most of the column types in SharePoint like Single line of text, Choice, Number, Date and Time, Yes/No (Boolean), Person or Group (single selection), etc.

For this afticle, we will use sorting based on SharePoint choice column as an example:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on column name/header from the list view and select either Ascending (A to Z) or Descending (Z to A) option from the popup menu:

Find internal name of SharePoint column by sorting choice column from SharePoint online modern experience list view
Find internal name of SharePoint column by sorting choice column

3. SharePoint will sort the list view based on selection and the browser URL will be changed like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?sortField=ChoiceColumn&isAscending=false

Where column name (ChoiceColumn) after sortField= is the internal name of your SharePoint choice column.

4. Similarly, when you use Filter by option in SharePoint modern experience to filter the list view based on Date and Time column (named as Start Date), SharePoint changes browser URL like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?FilterField1=Start_x0020_Date&FilterValue1=2023-04-05&FilterType1=DateTime

Where column name (Start_x0020_Date) after FilterField1= is the internal name of your SharePoint date and time column. Notice _x0020_ in internal column name which is an Unicode encoding of the space character in the display name of date and time column (Start Date).

Using Classic experience List settings page

Few of the SharePoint column types like Multiple lines of text, Hyperlink or Picture, Image, etc. does not support sorting or filtering from SharePoint modern experience list views. So, you have to use the classic experience list settings page to find the internal name for such SharePoint columns.

Follow below steps to find the internal name of multiple lines of text column using SharePoint classic experience list settings page:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on Settings (gear) icon from the top right corner and select List settings:

Open SharePoint online List settings page from modern experience list view to find the internal name of SharePoint column
Open SharePoint online list settings page

3. From list settings page, scroll down to the Columns section and click on the column name for which you want to find the internal name:

Open SharePoint online column settings page from classic experience list settings page to find the internal name of SharePoint column
Open SharePoint online Column settings page

4. SharePoint will open column settings page for the respective column with browser URL like:

https://contoso.sharepoint.com/sites/wlive/_layouts/15/FldEdit.aspx?List=%7B6FBA7FAE-AFC0-45D6-99EE-0AB20629EE41%7D&Field=MultilineTextCol
SharePoint online column settings page showing internal name of column
SharePoint online column settings page showing internal name of column

Where column name (MultilineTextCol) after Field= is the internal name of your SharePoint online multiple lines of text column.

Note: You can use this classic experience method to find out the internal name of SharePoint columns for all column types.

Using SharePoint REST API

You can use SharePoint REST API endpoint like below to get the internal name of SharePoint column based on it’s display name. Open URL in below format directly from browser tab:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/lists/getbytitle('InternalNames')/fields?$select=Title,InternalName&$filter=Title eq 'Multiline Text Column'
Find internal name of SharePoint online list column using SharePoint REST API
Find internal name of SharePoint column using SharePoint REST API
Using PnP PowerShell

You can use below PnP PowerShell script to find the internal name of SharePoint online list column using PnP PowerShell:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive
 
# Get internal name of SharePoint list column
Get-PnPField -Identity $columnName -List $listName | Select Title,InternalName
Find internal name of SharePoint online list column using PnP PowerShell
Find internal name of SharePoint column using PnP PowerShell
Using CLI for Microsoft 365

You can use below CLI for Microsoft 365 script to find the internal name of SharePoint online list column using CLI for Microsoft 365:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
	m365 login
}

# Get internal name of SharePoint list column
m365 spo field get --webUrl $siteUrl --listTitle $listName --title $columnName --output text
Find internal name of SharePoint online list column using CLI for Microsoft 365
Find internal name of SharePoint column using CLI for Microsoft 365

Best practices for naming SharePoint columns

When creating columns in SharePoint, it’s important to follow best practices for column naming to avoid using special characters or Unicode characters in internal names. Here are some recommended best practices:

  1. Use only alphanumeric characters: Stick to using letters (A-Z, a-z) and numbers (0-9) in column names. Avoid using special characters such as @, #, $, %, _, etc. Avoid column names beginning with numbers.
  2. Avoid spaces: Use PascalCase to separate words in column names instead of spaces. For example, use ColumnName instead of Column Name. This can help prevent issues with URLs, Unicode encoding, and referencing column names in scripts or code.
  3. Avoid reserved words: SharePoint has reserved words that are used for system functionality, and using them in column names may cause conflicts. Examples of reserved words include “ID”, “Modified”, “Created”, “Title”, etc. Avoid using these reserved words as column names.
  4. Keep it concise and meaningful: Use descriptive and meaningful names for columns that clearly indicate their purpose. Avoid using vague or generic names that may be confusing or ambiguous to users. Use column description to provide more information about the columns.
  5. Be consistent: Establish a consistent naming convention for columns across your SharePoint site or site collection to ensure uniformity and ease of management. This can also help with documentation, training, and maintenance of your SharePoint environment.

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

Learn more

Introduction to SharePoint Spaces

In this blog we will explore the SharePoint spaces, it’s history & roadmap and how to enable SharePoint spaces in a SharePoint online site.

What’s SharePoint Spaces

As per the Microsoft documentation, SharePoint spaces is defined as:

“SharePoint spaces is a web-based, immersive platform, which lets you create and share, secure and extensible mixed reality experiences. Add a new dimension to your intranet by using 2D and 3D web parts to create your mixed reality vision.”

SharePoint Spaces allows users to easily build mixed reality experiences that interact with content stored in SharePoint Online.

SharePoint spaces empower creators to build immersive mix reality experiences with point-and-click simplicity. You can get started with smart templates to create a mixed reality environment complete with beautiful surroundings, ambient sounds, rich textures, and lighting. You then add content, which can include files you already have in SharePoint, allowing you to repurpose your existing data, documents, and images.

History & Roadmap

  • Microsoft announced SharePoint Spaces first time during its annual SharePoint Virtual Summit held in May 2018.
  • Microsoft announced SharePoint spaces public preview in April 2020, Roadmap.
  • Microsoft added 360° tour web part in SharePoint spaces which allows creation of immersive virtual tours for SharePoint sites, Roadmap.
  • Microsoft added touch device support in SharePoint spaces which enables users to interact with a space using touch interactions in addition to the mouse and keyboard-based interactions, Roadmap.
  • Microsoft announced General Availability of SharePoint spaces, Roadmap.
Organization chart in SharePoint spaces in SharePoint online site
Org Chart in a SharePoint Space

That’s it for SharePoint spaces introduction and history. Let’s see how you can enable SharePoint spaces in your SharePoint online site to get started with it.

Enable SharePoint spaces in a site

SharePoint spaces are not enabled by default in SharePoint online site. To use SharePoint spaces, we need to enable a site feature named “Spaces”.

You can activate this feature using any one of the methods given below:

Manually:

You can activate Spaces feature from user interface by navigating to Manage site features page.

Hit (URL: https://tenant.sharepoint.com/sites/siteName/_layouts/ManageFeatures.aspx) in browser tab by replacing tenant and siteName or follow below steps:

  1. Go to SharePoint site where you want to build a space
  2. Click on Settings (gear icon), select Site information and then select View all site settings.
  3. On the Site settings page, select Manage site features under Site Actions.
  4. Scroll down the page to Spaces feature and click on Activate button.
  5. Wait till the page refreshes and confirm that feature is activated successfully.
SharePoint online site features settings
Activated Spaces feature
Using PnP PowerShell:

You can easily activate features in SharePoint online using PnP PowerShell. To activate a site feature using PnP PowerShell you will need the GUID of feature. Check how you can quickly get the GUID of a site feature. GUID of Spaces feature is 2ac9c540-6db4-4155-892c-3273957f1926.

Use below command to activate Spaces feature:

Enable-PnPFeature -Identity 2ac9c540-6db4-4155-892c-3273957f1926 -Scope Web

You can find the detailed example of how to activate a site feature in SharePoint Online using PnP PowerShell here.

To get an idea about what you can do using SharePoint spaces, check out some of the awesome samples here.

See also

Activate a site feature in SharePoint Online using PnP PowerShell

In my previous blog about Introduction to SharePoint Spaces, I explained different methods to enable SharePoint spaces in a SharePoint online site. One of the method was to activate a Spaces feature using PnP PowerShell.

So, I thought of writing a separate blog on how to activate a site feature in SharePoint Online using PnP PowerShell.

In SharePoint Online, we can easily activate a feature using Enable-PnPFeature cmdlet. To activate a feature using PnP PowerShell you will need the GUID of feature. Check how you can quickly get the GUID of a site feature.

In this blog, we will activate a site level feature named Spaces whose GUID is 2ac9c540-6db4-4155-892c-3273957f1926.

$siteUrl = "https://tenant.sharepoint.com/Sites/siteName"
$featureScope = "Web"	#Scope of feature 
$featureId = "2ac9c540-6db4-4155-892c-3273957f1926"	#SharePoint Spaces Feature
 
#Connect to SharePoint site
Connect-PnPOnline -Url $siteURL -Interactive
 
#Get Feature from SharePoint site
$spacesFeature = Get-PnPFeature -Scope $featureScope -Identity $featureId
 
#Check if feature is already activated or not
if($spacesFeature.DefinitionId -eq $null) {  
    Write-host "Activating Feature ($featureId)..." 
	
    #Activate the Feature
    Enable-PnPFeature -Scope Site -Identity $FeatureId -Force
 
    Write-host -f Green "Feature ($featureId) has been activated Successfully!"
}
else {
    Write-host "Feature ($featureId) is already active on this site!"
}

Output:

SharePoint online Site Features Settings in Manage site features
Activated Spaces feature

Similarly, you can also activate the site collection level features by changing -Scope to “Site”.

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

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

Remove an Organization Assets Library from SharePoint Online using PowerShell

In my previous blog post – Create an Organization Assets Library in SharePoint Online, I explained what is an Organization Assets Library in SharePoint, different types of organization assets libraries and provided a step-by-step guide on how to create organization assets libraries in SharePoint Online using SharePoint Online PowerShell, PnP PowerShell and CLI for Microsoft 365.

In this blog post, we will explore how to remove or unregister a SharePoint online document library from organization assets libraries using PnP PowerShell and CLI for Microsoft 365.

Using PnP PowerShell

You can use below PnP PowerShell script to remove a SharePoint document library that was designated as a central location for organization assets across the tenant:

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

# 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

# Remove organization assets library from SharePoint Online
Remove-PnPOrgAssetsLibrary -LibraryUrl $libraryUrl

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to unregister the given SharePoint Online document library as an organizational asset source in the tenant:

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

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

# Unregister a SharePoint document library from organization assets libraries
m365 spo orgassetslibrary remove --libraryUrl $libraryUrl --force

# Disconnect SharePoint online connection
m365 logout

Note: It might take up to 24 hours to remove an organization assets library from “Your organization” tab in the file/image picker after you unregister it from the SharePoint tenant organization asset libraries.

Learn more

Register SharePoint Document Library as an Organization Assets Library using PowerShell

In my previous blog post – Create an Organization Assets Library in SharePoint Online, I explained what is an Organization Assets Library in SharePoint, different types of organization assets libraries and provided a step-by-step guide on how to create organization assets libraries in SharePoint Online using SharePoint Online PowerShell.

In this blog post, we will explore how to register a SharePoint online document library as an organization assets library using PnP PowerShell and CLI for Microsoft 365. Before using below PowerShell scrips, follow this blog post until step #3 to create a SharePoint online communication site, granting proper permissions on the site and creating document libraries as per your requirements.

Using PnP PowerShell

You can use below PnP PowerShell script to register a SharePoint online document library as an organization assets library:

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

# Type of Organization assets 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-PnPOnline -Url $adminCenterUrl -Interactive

# Register a document library as an organization assets library
Add-PnPOrgAssetsLibrary -LibraryUrl $libraryUrl -OrgAssetType $orgAssetType

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to register a SharePoint document library as an organization assets library for images:

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

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

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

# Register a SharePoint document library as an organization asset library
m365 spo orgassetslibrary add --libraryUrl $libraryUrl --orgAssetType $orgAssetType

# Disconnect SharePoint online connection
m365 logout

Note: You need SharePoint tenant administrator permissions to run above PowerShell scripts.

Learn more

Disable Quick property editing (Grid view) from SharePoint Online list

SharePoint Online and Microsoft Lists offers a multitude of features to enhance collaboration and streamline data management. One such feature is the Quick Property Editing (Edit in Grid view), which allows users to bulk edit metadata for multiple list items directly from the list view. While this feature can improve efficiency, there are scenarios where disabling it becomes necessary. In this blog post, we’ll explore various methods to achieve this in SharePoint Online.

From SharePoint UI

Follow below steps to disable quick edit (Edit in grid view) from SharePoint list UI:

1. Go to your SharePoint Online list.

2. Click on Settings (gear icon) from the top right corner and select List settings.

3. Click on Advanced settings link from List settings page.

4. From Advanced settings page, scroll down and set Quick property editing (Allow items in this list to be edited using Quick Edit and the Details Pane?) to No.

5. Click OK button at the bottom of advanced list settings page.

Using PnP PowerShell

You can use below PnP PowerShell script to disable Quick property editing (Grid view) from SharePoint Online list or document library:

# Display name of SharePoint online list or document library
$listName = "My SharePoint List"

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

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

# Disable Quick property editing (Grid view) from SharePoint list
Set-PnPList -Identity $listName -DisableGridEditing $true

Write-Host "Done! :-)" -ForegroundColor Green

# Disconnect SharePoint online connection
Disconnect-PnPOnline

You can set -DisableGridEditing to $false to enable the quick edit (edit in grid view) back to your SharePoint list.

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to disable Quick property editing (Edit in grid view) from SharePoint Online or Microsoft Lists:

# Display name of SharePoint online list or document library
$listName = "My SharePoint List"

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

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

# Disable Quick property editing (Grid view) from SharePoint list
m365 spo list set --webUrl $siteUrl --title $listName --disableGridEditing true

Write-Host "Done! :-)" -ForegroundColor Green

# Disconnect SharePoint online connection
m365 logout

You can set --disableGridEditing to false to enable the quick property editing (edit in grid view) for your SharePoint online list.

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

Set a page template as default page template in SharePoint Online

SharePoint Online is a powerful collaboration and content management platform that allows organizations to create and manage sites for various purposes. One of the key features that enhances site design and improves user experience is the use of Page Templates. In this blog post, we will delve into what are page templates in SharePoint online and how to set a default page template for a SharePoint site.

What are Page Templates in SharePoint?

Page templates in SharePoint Online are pre-designed layouts or structures that provide a consistent and standardized format for creating site pages within a site. They serve as a starting point for designing and organizing content on SharePoint pages, ensuring a cohesive look and feel across the site.

Page templates can include a variety of elements such as placeholders for text, images, web parts, page sections, and more. By using page templates, users can quickly create new pages with a predefined structure and layout, saving time and effort while maintaining visual consistency.

Setting a Default Page Template for a SharePoint Site

When users try to create new site pages from SharePoint site home page, the default selected template in the Page Templates pane is Blank. If users don’t select a different template, the blank template will be used for their new page.

If you prefer to have another custom page template be the default selection for your SharePoint site while creating new site pages, follow one of the methods given below:

Using SharePoint User Interface

Follow below steps to set a default page template for your SharePoint online site from SharePoint UI:

1. Go to home page of your SharePoint online site.

2. Click on New from page command bar and select Page:

Open Page templates pane from SharePoint online site home page
Open Page templates pane from SharePoint online site home page

3. Click on vertical ellipses at the bottom right side of the template you want, and then select Set default selection:

Set default selection of page template for SharePoint online site
Set default selection of page template for SharePoint site

4. Click OK from Changing default selection confirmation popup.

Note: When you change the default selection in the page templates pane, it will be changed for all users in the SharePoint site.

Using PnP PowerShell

You can use below PnP PowerShell script to set a page template as default page template for SharePoint online 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

# Get page template details and Unique ID
$page = Get-PnPFile -Url "/sites/work/SitePages/Templates/PlainHeaderNoComments.aspx" -AsListItem

# Set a page template as default page template for SharePoint online site
Set-PnPPropertyBagValue -Key DefaultNewPageTemplateId -Value $page["UniqueId"]

# Disconnect SharePoint online connection
Disconnect-PnPOnline

You may get error like below while executing above PnP PowerShell script if custom scripts are not enabled for your SharePoint site:

Set-PnPPropertyBagValue: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Site might have NoScript enabled, this prevents setting some property bag values.

In that case, you have to first enable the custom scripts for your SharePoint site by following: Allow use of custom scripts in SharePoint Online using PowerShell.

Using CLI for Microsoft 365

Use below CLI for Microsoft 365 script to set a page template as default page template for SharePoint online site:

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

# SharePoint online site URL
$siteUrl = Read-Host -Prompt "Enter your SharePoint site URL (e.g https://contoso.sharepoint.com/sites/work)"
 
# Get page template details and Unique ID
$page = m365 spo file get --webUrl $siteUrl --url '/sites/work/SitePages/Templates/PlainHeaderNoComments.aspx' | ConvertFrom-Json

# Set a page template as default page template for SharePoint online site
m365 spo propertybag set --webUrl $siteUrl --key DefaultNewPageTemplateId --value $page.UniqueId

If custom scripts are not enabled for your SharePoint site, above CLI for Microsoft 365 script will throw error like:

Error: Site has NoScript enabled, and setting property bag values is not supported

In that case, you have to first enable the custom scripts for your SharePoint online site by following: Allow use of custom scripts in SharePoint Online using PowerShell.

Conclusion

Page templates in SharePoint online provide a valuable tool for enhancing site design and improving user experience. By setting a default page template, organizations can establish a consistent and standardized format for creating web pages within their SharePoint sites. This not only saves time but also ensures a cohesive and professional look across the site. By leveraging page templates, organizations can effectively showcase their content while maintaining their branding and style guidelines.

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

How to find the Internal name of columns in SharePoint Online?

The internal name of a SharePoint column is a unique name that is automatically generated by SharePoint when a column is created. It is used by SharePoint internally to reference and retrieve the value of a particular column associated with an item or document. The internal name is generated based on the display name you provide but all special characters and spaces will be replaced with Unicode’s by SharePoint. Internal name is generated only once while creating a new column and it cannot be changed even if you change the display name of SharePoint column.

The internal name is not visible to users in the SharePoint user interface by default, but it is commonly used in various scenarios, such as in SharePoint REST APIs, Power Automate flow expressions, Power Apps formulas, PowerShell, etc. to interact with column data programmatically.

Where are Internal names of SharePoint columns used?

  1. Custom Scripts: When creating custom scripts, such as JavaScript or PowerShell, the internal names of columns are required to reference and manipulate the values of the columns while interacting with SharePoint data.
  2. Workflows: In SharePoint Designer workflows or Microsoft Power Automate (formerly known as Microsoft Flow), the internal names of columns are used to reference the values of the columns as inputs or outputs in the workflow actions and in expressions.
  3. Custom Solutions: When building custom solutions, such as SharePoint apps, SharePoint framework (SPFx) web parts, or custom code, the internal names of columns are required to interact with the columns programmatically.
  4. Power Apps: Few of the Power Apps functions like ShowColumns, SortByColumns, etc. requires using internal names of SharePoint columns in formula.
  5. JSON Formatting: Internal name of SharePoint column is required in JSON formatting to reference the column value with [$InternalNameOfColumn] syntax.

How to find the Internal name of a SharePoint column?

Using Modern experience list view

You can use sorting or filtering options from SharePoint online modern experience list view to find the internal name of a SharePoint column. Sort by and Filter by options are supported by most of the column types in SharePoint like Single line of text, Choice, Number, Date and Time, Yes/No (Boolean), Person or Group (single selection), etc.

For this afticle, we will use sorting based on SharePoint choice column as an example:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on column name/header from the list view and select either Ascending (A to Z) or Descending (Z to A) option from the popup menu:

Find internal name of SharePoint column by sorting choice column from SharePoint online modern experience list view
Find internal name of SharePoint column by sorting choice column

3. SharePoint will sort the list view based on selection and the browser URL will be changed like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?sortField=ChoiceColumn&isAscending=false

Where column name (ChoiceColumn) after sortField= is the internal name of your SharePoint choice column.

4. Similarly, when you use Filter by option in SharePoint modern experience to filter the list view based on Date and Time column (named as Start Date), SharePoint changes browser URL like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?FilterField1=Start_x0020_Date&FilterValue1=2023-04-05&FilterType1=DateTime

Where column name (Start_x0020_Date) after FilterField1= is the internal name of your SharePoint date and time column. Notice _x0020_ in internal column name which is an Unicode encoding of the space character in the display name of date and time column (Start Date).

Using Classic experience List settings page

Few of the SharePoint column types like Multiple lines of text, Hyperlink or Picture, Image, etc. does not support sorting or filtering from SharePoint modern experience list views. So, you have to use the classic experience list settings page to find the internal name for such SharePoint columns.

Follow below steps to find the internal name of multiple lines of text column using SharePoint classic experience list settings page:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on Settings (gear) icon from the top right corner and select List settings:

Open SharePoint online List settings page from modern experience list view to find the internal name of SharePoint column
Open SharePoint online list settings page

3. From list settings page, scroll down to the Columns section and click on the column name for which you want to find the internal name:

Open SharePoint online column settings page from classic experience list settings page to find the internal name of SharePoint column
Open SharePoint online Column settings page

4. SharePoint will open column settings page for the respective column with browser URL like:

https://contoso.sharepoint.com/sites/wlive/_layouts/15/FldEdit.aspx?List=%7B6FBA7FAE-AFC0-45D6-99EE-0AB20629EE41%7D&Field=MultilineTextCol
SharePoint online column settings page showing internal name of column
SharePoint online column settings page showing internal name of column

Where column name (MultilineTextCol) after Field= is the internal name of your SharePoint online multiple lines of text column.

Note: You can use this classic experience method to find out the internal name of SharePoint columns for all column types.

Using SharePoint REST API

You can use SharePoint REST API endpoint like below to get the internal name of SharePoint column based on it’s display name. Open URL in below format directly from browser tab:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/lists/getbytitle('InternalNames')/fields?$select=Title,InternalName&$filter=Title eq 'Multiline Text Column'
Find internal name of SharePoint online list column using SharePoint REST API
Find internal name of SharePoint column using SharePoint REST API
Using PnP PowerShell

You can use below PnP PowerShell script to find the internal name of SharePoint online list column using PnP PowerShell:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive
 
# Get internal name of SharePoint list column
Get-PnPField -Identity $columnName -List $listName | Select Title,InternalName
Find internal name of SharePoint online list column using PnP PowerShell
Find internal name of SharePoint column using PnP PowerShell
Using CLI for Microsoft 365

You can use below CLI for Microsoft 365 script to find the internal name of SharePoint online list column using CLI for Microsoft 365:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
	m365 login
}

# Get internal name of SharePoint list column
m365 spo field get --webUrl $siteUrl --listTitle $listName --title $columnName --output text
Find internal name of SharePoint online list column using CLI for Microsoft 365
Find internal name of SharePoint column using CLI for Microsoft 365

Best practices for naming SharePoint columns

When creating columns in SharePoint, it’s important to follow best practices for column naming to avoid using special characters or Unicode characters in internal names. Here are some recommended best practices:

  1. Use only alphanumeric characters: Stick to using letters (A-Z, a-z) and numbers (0-9) in column names. Avoid using special characters such as @, #, $, %, _, etc. Avoid column names beginning with numbers.
  2. Avoid spaces: Use PascalCase to separate words in column names instead of spaces. For example, use ColumnName instead of Column Name. This can help prevent issues with URLs, Unicode encoding, and referencing column names in scripts or code.
  3. Avoid reserved words: SharePoint has reserved words that are used for system functionality, and using them in column names may cause conflicts. Examples of reserved words include “ID”, “Modified”, “Created”, “Title”, etc. Avoid using these reserved words as column names.
  4. Keep it concise and meaningful: Use descriptive and meaningful names for columns that clearly indicate their purpose. Avoid using vague or generic names that may be confusing or ambiguous to users. Use column description to provide more information about the columns.
  5. Be consistent: Establish a consistent naming convention for columns across your SharePoint site or site collection to ensure uniformity and ease of management. This can also help with documentation, training, and maintenance of your SharePoint environment.

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

Learn more

find-internal-name-of-sharepoint-column-by-sorting-choice-column

ganeshsanapblogs

Find internal name of SharePoint column by sorting choice column from SharePoint online modern experience list view

Open SharePoint online List settings page from modern experience list view to find the internal name of SharePoint column

Open SharePoint online column settings page from classic experience list settings page to find the internal name of SharePoint column

SharePoint online column settings page showing internal name of column

Find internal name of SharePoint online list column using SharePoint REST API

Find internal name of SharePoint online list column using PnP PowerShell

Find internal name of SharePoint online list column using CLI for Microsoft 365

Set SharePoint site home page using PnP PowerShell and CLI for Microsoft 365

SharePoint site home page provides a centralized location where users can access important information such as news, announcements, quick links and documents. This can help users stay informed and up-to-date on the latest company news and updates.

SharePoint site home page can be customized to include quick links to commonly used tools and applications, which can help users save time and increase productivity.

In this blog, we will look at how to use PnP PowerShell and CLI for Microsoft 365 to set a SharePoint modern page as the home page for SharePoint online site. You can use either of below scripts to make a newly created site page or an existing site page as the homepage for your SharePoint site.

Using PnP PowerShell

Once you have a modern site page ready in Site Pages library of your SharePoint site, you can use below PnP PowerShell script to make your site page as the homepage of your SharePoint site:

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

# Name of your SharePoint site page
$sitePageName = "NewHome.aspx"

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

# Set SharePoint site home page using PnP PowerShell
Set-PnPHomePage -RootFolderRelativeUrl SitePages/$sitePageName

Using CLI for Microsoft 365

You can use below CLI for Microsoft script to set your site page as the homepage of your SharePoint online site:

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

# Name of your SharePoint site page
$sitePageName = "NewHome.aspx"

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

# Set SharePoint site home page using CLI for Microsoft 365
m365 spo web set --url $siteUrl --welcomePage "SitePages/$sitePageName"

Note

You have to install latest versions of PnP PowerShell and CLI for Microsoft 365 before running above scripts. Follow below documentations for installing PnP PowerShell and CLI for Microsoft 365:

Once you run either of above scripts successfully and navigate to SharePoint online site, you will see that new home page is set for your SharePoint online site:

Set SharePoint online site home page using PnP PowerShell and CLI for Microsoft 365 in modern experience
Set SharePoint site home page using PnP PowerShell and CLI for Microsoft 365

Learn more

set-sharepoint-site-home-page-using-pnp-powershell-and-cli-for-microsoft-365

ganeshsanapblogs

Set SharePoint online site home page using PnP PowerShell and CLI for Microsoft 365 in modern experience

❌
❌