Update list icons & color
Summary
With a recent change in SharePoint Online, lists now have a icon and a color. However the defaults seem kinda random, this script demonstrates how to change the icons, and the colors, including mapping the current colors and icons to enums to make it easier to work with.
function get-customFormatting() {
Connect-PnPOnline "Site Url"
Enum Icons {
Bug = 0
Calendar = 1
Target = 2
Clipboard = 3
Plane = 4
Rocket = 5
ColorPalette = 6
Lightbulb = 7
Cube = 8
Beaker = 9
Robot = 10
PiggyBank = 11
Playlist = 12
Hospital = 13
Bank = 14
MapPin = 15
CoffeCup = 16
ShoppingCart = 17
BirthdayCake = 18
}
Enum Color {
DarkRed = 0
Red = 1
Orange = 2
Green = 3
DarkGreen = 4
Teal = 5
Blue = 6
NavyBlue = 7
BluePurple = 8
DarkBlue = 9
Lavender = 10
Pink = 11
}
$list = Get-PnPList "ListName";
$list.Icon = [int][Icons]::Rocket;
$list.Color = [int][Color]::NavyBlue;
$list.Update()
Invoke-PnPQuery
# Notice!
# I've also submitted a pull request to PnP PowerShell which would allow you to do all this inline.
# but as of now that hasn't been accepted, but in the future the below command might work for you
# Set-PnPList "ListName" -Color NavyBlue -Icon Rocket
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?
Contributors
Author(s) |
---|
Dan Toft |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.