Skip to content

Commit 582aa68

Browse files
committed
Added CTH variation of the script
1 parent 12f00ea commit 582aa68

File tree

1 file changed

+48
-2
lines changed
  • scripts/spo-document-sets-modern-new-form

1 file changed

+48
-2
lines changed

scripts/spo-document-sets-modern-new-form/README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
## Summary
66

7-
I've found that setting the NewFormClientSideComponentId to _NULL_ on a documents set content type will cause it to render a modern creation form over the default, this script will help you do that.
8-
7+
I've found that setting the NewFormClientSideComponentId to _NULL_ on a documents set content type will cause it to render a modern creation form over the default, this script will help you do that. (Also see alternate version below, which works on the Content Type Hub.)
98

109
![Outupt Screenshot](assets/output.png)
1110

@@ -47,6 +46,51 @@ Invoke-PnPQuery
4746
Write-Host -ForegroundColor Green "All done"
4847
4948
```
49+
50+
This alternate version, based on Dan's script above, works on the Content Type Hub, allowing you to modernize Document Sets stored at the enterprise level. See [Modernizing the Document Set NewDocSet Form](https://sympmarc.com/2025/06/12/modernizing-the-document-set-newdocset-form/) for more details
51+
52+
```powershell
53+
$tenant = "YourTenantName"
54+
$clientId = "YourAppRegistrationGUID"
55+
56+
$cthConnection = Connect-PnPOnline -ClientId $clientId -Url "https://$($tenant).sharepoint.com/sites/ContentTypeHub" -Interactive
57+
58+
# Get the "Document Set" content types
59+
$cts = Get-PnPContentType | Where-Object { $_.Id.StringValue.StartsWith("0x0120D520") }
60+
61+
foreach ($ct in $cts) {
62+
$currVal = "❌"
63+
if($ct.NewFormClientSideComponentId.Length -eq '') {
64+
$currVal = "✅"
65+
}
66+
Write-Host "[$($cts.IndexOf($ct)+1)] $($ct.name) $($currVal)"
67+
}
68+
69+
$CTindex = Read-Host -Prompt "Which content type to you wish to modernize"
70+
71+
# Null out the NewFormClientSideComponentId as that seems to bring it to modern UI
72+
$cts[$CTindex - 1].NewFormClientSideComponentId = $null;
73+
$cts[$CTindex - 1].Update($false);
74+
75+
Invoke-PnPQuery
76+
77+
$ctPub = Read-Host -Prompt "Content Type $($cts[$CTindex-1].Name) updated. Would you like to publish the change? (Y/N)"
78+
if ($ctPub -ne 'Y' -and $ctPub -ne 'y') {
79+
Write-Host -ForegroundColor Red "Exiting without publishing changes."
80+
exit
81+
}
82+
else {
83+
# Publish the changed content type
84+
Write-Host -ForegroundColor Yellow "Publishing content type $($cts[$CTindex-1].Name) with ID $($cts[$CTindex-1].Id)"
85+
Publish-PnPContentType -ContentType $cts[$CTindex - 1].Id
86+
}
87+
88+
Write-Host -ForegroundColor Green "All done"
89+
90+
```
91+
92+
93+
5094
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
5195
***
5296

@@ -55,6 +99,8 @@ Write-Host -ForegroundColor Green "All done"
5599
| Author(s) |
56100
| ---------------------------------- |
57101
| Dan Toft(https://blog.dan-toft.dk) |
102+
| Marc D Anderson (https://sympmarc.com) |
103+
58104

59105
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
60106
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-document-sets-modern-new-form" aria-hidden="true" />

0 commit comments

Comments
 (0)