-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #623 from Amanp17/main
pnp-reorder-list-content-type
- Loading branch information
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
plugin: add-to-gallery | ||
--- | ||
|
||
# Reorder Content Types in SharePoint List | ||
|
||
## Summary | ||
|
||
This guide details how to rearrange content types in a SharePoint list using PnP PowerShell. | ||
|
||
![Example Screenshot](assets/ContentTypes.png) | ||
|
||
|
||
# [PnP PowerShell](#tab/pnpps) | ||
|
||
```powershell | ||
# Specify the Site URL | ||
$SiteURL = "https://contoso.sharepoint.com/" | ||
# Connect to SharePoint online admin center | ||
Connect-PnPOnline -Url $SiteURL -Interactive | ||
# Note Down the Content Types order you need | ||
$ContentTypesOrder = @("Site Page","Web Part Page","Wiki Page","Repost Page") | ||
# Specify the List Name | ||
$ListName = "Site Pages" | ||
#Get the List Details | ||
$List = Get-PnPList -Identity $ListName -Includes ContentTypes,RootFolder.UniqueContentTypeOrder | ||
#Create a List for content types order | ||
$ContentTypeOrder = New-Object System.Collections.Generic.List[Microsoft.SharePoint.Client.ContentTypeId] | ||
#Arrange Content Types Order | ||
ForEach($ContentType in $ContentTypesOrder) | ||
{ | ||
#Get the Content Type from List and Add to Content Type Order List | ||
$CType = $List.ContentTypes | Where {$_.Name -eq $ContentType} | ||
If($CType -ne $Null) | ||
{ | ||
$ContentTypeOrder.Add($CType.Id) | ||
} | ||
} | ||
#Set Content type Order | ||
$List.RootFolder.UniqueContentTypeOrder = $ContentTypeOrder | ||
$List.RootFolder.Update() | ||
Invoke-PnPQuery | ||
# Disconnect SharePoint online connection | ||
Disconnect-PnPOnline | ||
``` | ||
|
||
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)] | ||
|
||
*** | ||
|
||
## Contributors | ||
|
||
| Author | | ||
|-----------| | ||
| [Aman Panjwani](https://www.linkedin.com/in/aman-17-panjwani/) | | ||
|
||
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)] | ||
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-reorder-list-content-type" aria-hidden="true" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[ | ||
{ | ||
"name": "spo-reorder-list-content-type", | ||
"source": "pnp", | ||
"title": "Reorder Content Types in SharePoint List", | ||
"shortDescription": "This script guides how to rearrange content types in a SharePoint list using PnP PowerShell.", | ||
"url": "https://pnp.github.io/script-samples/spo-reorder-list-content-type/README.html", | ||
"longDescription": [ | ||
"This comprehensive guide provides step-by-step instructions on efficiently reordering content types within a SharePoint list, leveraging the capabilities of PnP PowerShell. Streamline your information organization" | ||
], | ||
"creationDateTime": "2023-11-15", | ||
"updateDateTime": "2023-11-15", | ||
"products": [ | ||
"SharePoint" | ||
], | ||
"metadata": [ | ||
{ | ||
"key": "PNP-POWERSHELL", | ||
"value": "2.1.1" | ||
} | ||
], | ||
"categories": [ | ||
"Configure" | ||
], | ||
"tags": [ | ||
"SharePoint Online", | ||
"ContentTypes", | ||
"Connect-PnPOnline", | ||
"Invoke-PnPQuery", | ||
"Disconnect-PnPOnline" | ||
], | ||
"thumbnails": [ | ||
{ | ||
"type": "image", | ||
"order": 100, | ||
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-reorder-list-content-type/assets/preview.png", | ||
"alt": "Content Types in SharePoint Lists" | ||
} | ||
], | ||
"authors": [ | ||
{ | ||
"gitHubAccount": "Amanp17", | ||
"pictureUrl": "https://github.com/Amanp17.png", | ||
"name": "Aman Panjwani" | ||
} | ||
], | ||
"references": [ | ||
{ | ||
"name": "Want to learn more about PnP PowerShell and the cmdlets", | ||
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.", | ||
"url": "https://aka.ms/pnp/powershell" | ||
} | ||
] | ||
} | ||
] |