Vue normale

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

Create Colored Folders in SharePoint Online using CLI for Microsoft 365

In my previous blog post Creating Colored Folders in SharePoint Online and OneDrive, we saw how to create colored folders in SharePoint online document libraries and OneDrive for Business using user interface (UI) from browser. In this blog post, we’ll explore how to create colorful folders in SharePoint Online using CLI for Microsoft 365, a powerful command-line tool that extends SharePoint’s capabilities.

This new feature of coloring SharePoint & OneDrive folders allows users to assign a color label to folders, providing a visual cue for organization and categorization. However, it’s essential to understand how this works internally and what values are used for coloring folders in SharePoint Online and OneDrive for Business.

Thanks to Tetsuya Kawahara and his PnP PowerShell script sample at Create Colored Folder which explains SharePoint uses the column with internal name as _ColorHex to store the color setting information of folders. The _ColorHex field is a hidden field within SharePoint libraries, and it is not visible by default in standard views. This field stores the color as a numeric value corresponding to each color.

SharePoint supports a predefined set of 16 numerical color values that can be used to color folders. The following table shows the numerical values corresponding to each color:

Color_ColorHex value
YellowEmpty or 0
Dark red1
Dark orange2
Dark green3
Dark teal4
Dark blue5
Dark purple6
Dark pink7
Grey8
Light red9
Light orange10
Light green11
Light teal12
Light blue13
Light purple14
Light pink15

We will see how to use these _ColorHex column values to create a new folder in SharePoint online document library using CLI for Microsoft 365 below:

Step 1: Install the CLI for Microsoft 365

Before we can start working with the CLI for Microsoft 365, we need to install it. You can install the CLI for Microsoft 365 by using below NPM commands or by following the instructions on the official documentation page:  CLI for Microsoft 365 – Installation.

npm install -g @pnp/cli-microsoft365

You have to use below command if you want to install beta version of CLI for Microsoft 365:

npm install -g @pnp/cli-microsoft365@next

Step 2: Create colored folder using CLI for Microsoft 365

After installation of CLI for Microsoft 365,  you can use below CLI for Microsoft 365 script to create a new colored folder in SharePoint online document library using CLI for Microsoft 365:

# Set Variables
$siteUrl = "https://contoso.sharepoint.com/sites/work"
$relativeUrlOfParentFolder = "/ColoredFolders"
$documentLibraryDisplayName = "Colored Folders"
$folderName = "Confidential"
$folderColor = 1

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

    # Create the folder
    $newFolder = m365 spo folder add --webUrl $siteUrl --parentFolderUrl $relativeUrlOfParentFolder --name $folderName | ConvertFrom-Json

    # Get the created folder item
    $newFolderItem = m365 spo listitem get --webUrl $siteUrl --listTitle $documentLibraryDisplayName --uniqueId $newFolder.UniqueId | ConvertFrom-Json

    # Change the value of the _ColorHex column of the created folder to change the color
    m365 spo listitem set --webUrl $siteUrl --listTitle $documentLibraryDisplayName --id $newFolderItem.Id --_ColorHex $folderColor

    Write-Host "Folder created and color changed successfully." -ForegroundColor Green
    Write-Host "Folder URL: $siteUrl/$relativeUrlOfParentFolder/$folderName" -ForegroundColor Green
}
catch {
    Write-Host "An error occurred: $_" -ForegroundColor Red
}
finally {
    # Disconnect from SharePoint site
    m365 logout
}

Once you run above script successfully and navigate to SharePoint document library, you will see that new colored folder is created inside the SharePoint document library as given below: 

Create Colored Folders in SharePoint Online using CLI for Microsoft 365
Colored folders created in SharePoint Online using CLI for Microsoft 365

Conclusion

Adding color to your folders in SharePoint Online document libraries using CLI for Microsoft 365 is a simple yet effective way to enhance the visual organization and management of your documents. This can improve user experience and help users quickly identify and access the content they need. Experiment with different colors and organizational schemes to find what works best for your team or organization.

Learn more

Creating Colored Folders in SharePoint Online and OneDrive

In today’s digital age, organizing and managing your files and folders efficiently is crucial. SharePoint Online and OneDrive, both part of the Microsoft 365 suite, offer powerful tools for document management and collaboration. While they provide a variety of features to help you stay organized, adding a touch of color to your folders can make a significant difference in terms of visual clarity and user experience. In this blog post, we’ll explore how to create colorful folders in SharePoint Online and OneDrive, making your document management experience more visually appealing and efficient.

Microsoft is currently rolling out a new feature for SharePoint Online document libraries and  OneDrive for Business which will allow users to colorize their folders with a pre-set range of 16 colors. This colorization is applicable to both new and already existing folders. You can find more details about this feature and release timeline with Microsoft Roadmap ID 124980.

Create a new colored folder in SharePoint Online

Follow below steps to create a new colored folder in SharePoint Online document library:

1. Go to your SharePoint online document library

2. Click on + New button from document library command bar and select Folder

3. Enter name for your new folder, select desired color under Folder color option and click Create to create a new colored folder:

Create a new colored folder in SharePoint Online Document Library
Create a new colored folder in SharePoint Online document library

Create a new colored folder in OneDrive for Business

Follow below steps to create a new colored folder in OneDrive for Business:

1. Go to your personal account in OneDrive for Business and select My Files from left navigation pane

2. Click on + Add New button from top left corner and select Folder

3. Enter name for your new folder, select desired color under Folder color option and click Create to create a new colored folder:

Create a new colored folder in OneDrive for Business and SharePoint Online
Create a new colored folder in OneDrive for Business

Note: Colored folders can only be viewed in My Files in OneDrive for Business with this feature rollout.

Change color of existing folder in SharePoint Online or OneDrive for Business

If you already have existing folders in SharePoint Online or OneDrive for Business and you want to change the color, you can do it directly from the folder context menu or through the rename folder option.

1. Go to your SharePoint online document library or OneDrive for Business

2. Locate the folder for which you want to change the color

3. Select the folder and open folder context menu – click on ellipses () if you are using List view OR right/second click on folder if you are using Tiles view

4. Use Rename or Folder color options to update the color of existing folders in SharePoint online document library or OneDrive for Business:

Change color of existing folder in SharePoint Online document library or OneDrive for Business
Change color of existing folder in SharePoint Online document library

Conclusion

Adding color to your folders in SharePoint Online and OneDrive for Business is a simple yet effective way to enhance your document management experience. It brings visual clarity, simplifies organizing folders, and helps prioritize tasks. Whether you’re using SharePoint for team collaboration or OneDrive for personal file storage, this feature can be a game-changer in keeping your digital workspace neat and efficient. Give it a try and experience the benefits of a visually appealing and well-organized document library!

Learn more

Sync folder vs. Sync Library in SharePoint and OneDrive

I documented the mechanism of OneDrive Sync quite extensively on my blog previously. However, one thing I did not mention before was the difference between syncing the whole library vs. just a folder within a document library. So in this article, I want to explore what will happen when you Sync a folder instead of a document library and some unexpected consequences that might occur.

What is OneDrive Sync?

If you are wondering what I am talking about, please check out this post, where I explain in great detail OneDrive Sync and how it works.

OneDrive Sync of a Document Library

When you sync the whole document Library (which is probably the most common occurrence), by clicking the Sync button at a library level, it syncs the entire document library to your PC, all the folders and subfolders inside of it.

Sync folder vs. Sync Library

Syncing the entire library from SharePoint

This is how the synchronized document library appears on the PC

The naming convention for the synchronized library on your computer is “Site Name – Document Library Name.” For example, in my case, it is HR Team – Documents, where HR Team is the site name and Documents is the name of a document library.

OneDrive Sync of a folder within a document library

If, instead, you decide to sync just a specific folder from your SharePoint site, by clicking the button at a folder level, it will only synchronize that folder and everything inside.

Syncing a specific folder from SharePoint

Sync folder vs. Sync Library

This is how the synchronized folder appears on the PC

The naming convention for the synchronized folders on your computer is “Site Name – Folder Name.” For example, in my case, it is HR Team – Clients, where HR Team is the site name and Clients is the name of a folder within the Documents library.

Syncing a folder and a library together – unintended consequences

Since nothing stops you from clicking the Sync button at both folder and library levels, I want to highlight a few unintended consequences that might occur as a result.

Scenario 1: Sync the document library first, then sync a folder

In case you sync the library first and then decide to sync the folder inside of that library – nothing will really happen. Since you are already syncing the entire library, clicking the Sync button at a folder level won’t do anything extra. So all is good in this case.

Scenario 2: Sync the folder first, then sync the entire document library

If you do this in the opposite order, this will lead to potential confusion for the users and even possible loss of information/track of changes. This only occurs when you disable Files On-Demand – in other words, physically download the files and folders on your PC.

Here is an issue:

  1. In the example below, I have a document library with a few folders inside
  2. I then sync one of the folders first (the Clients folder in my case). It syncs it onto my PC and makes it available from Windows Explorer (as expected).Sync folder vs. Sync Library
  3.  I then click the Sync button on the entire document library. At this point, it syncs the entire document library with all of its subfolders inside to Windows Explorer, but simultaneously, it stops the sync of the folder I synchronized previously.
  4. It does not remove the folder from Windows Explorer. It just leaves it in place and synchronizes a document library next to it. It does remove the “green checkbox” over the folder, indicating that the folder is no longer synchronized to SharePoint. However, if the user continues to access files in that folder or update them, none of those changes will make it to the cloud! 😠
  5. So to summarize, if you sync any folders first and then decide to synchronize the entire document library, you must immediately delete the folder from your PC to avoid confusion and possible data loss.

Alternatives to folder syncing

So the best practice to avoid the above-described headache would be to sync the entire libraries and not sync folders.

If you do need to sync just a certain folder or set of folders and not the entire library, I highly recommend syncing the entire library, but then doing the selective sync. I described it in this article.

The post Sync folder vs. Sync Library in SharePoint and OneDrive appeared first on SharePoint Maven.

In Site Library vs. In Channels Folders

If you recently navigated to a SharePoint team Sites, you probably have noticed an interesting breakdown of files and folders on that site. Suddenly, all the folders are grouped into two groupings: In Site Library vs. In Channels. So today, I want to explain why we have such a grouping in the first place.

In Site Library vs. In Channels

The impact of Microsoft Teams

The phenomena described above only occur on Team Sites connected to Teams. As you probably already know from reading my blog posts, when you create a new Team in Teams, it also creates a SharePoint site behind the scenes.

The Teams application uses SharePoint for file management capabilities. You can read more about this here.

How folders are created on a Team Site

There are three types of folders you can have on a Team Site.

  1. Folders that are created by virtue of the Standard Channels
  2. Folders that are created manually by users
  3. Folders that look like folders but are just links to Private and Shared Channels

I will explain all three types of these folders further below.

1. Standard Channels = Folders

As I described pretty extensively in this article, every time you create a Standard Channel in Teams, a folder is created with the same name on an associated SharePoint site. So when you click on a Files Tab inside a given channel in Teams, you are just viewing the contents of the channel folder on a SharePoint site.

Example of a Files Tab inside the Standard Channel in Teams

Example of a Files Tab inside the Standard Channel in Teams

Example of the same channel folder on a SharePoint Site

Example of the same channel folder on a SharePoint Site

2. Manually created folders

And, of course, the second type of folder you can create is the one you create manually within the SharePoint site/document library. Those folders are just a way to organize your files and folders outside of any channel.

In Site Library vs. In Channels

3. Folders that are links to Private and Shared Channels

If you expand a drop-down under In Channels on a SharePoint site, you might notice folders corresponding to Private and Shared Channels on your Team. I say “might” because not all Teams have private or shared channels; you obviously will not see those folders if your Team does not have any.

The folders will have the same icons as in Teams, designating either a Private or Shared channel.

In Site Library vs. In Channels

However, these Private and Shared folders are not really folders. As documented in an earlier post, every time you create a Private or Shared Channel in Teams, it creates a separate SharePoint site for that channel. So these “folders” are just links to respective Private Channel and Shared Channel Sites. For example, clicking on Financials “folder” above redirects you to the separate SharePoint site created to accommodate that Financials Private Channel.

Private Channel SharePoint Site created to store Private Channel documents

Private Channel SharePoint Site created to store Private Channel documents

In summary: In Site Library vs. In Channels Folders

  • In Channels – shows you the folders that correspond to Standard Channels in Teams + folders that link you to the Private and Shared Channel sites (if those types of channels exist in a Team).
  • In Site Library – shows you the folders that correspond to Standard Channels in Teams + folders manually created by users at the root of the document library.

The post In Site Library vs. In Channels Folders appeared first on SharePoint Maven.

❌
❌