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

❌
❌