diff --git a/scripts/spo-add-fields-to-contenttypes/README.md b/scripts/spo-add-fields-to-contenttypes/README.md index 71daec97a..3906452f2 100644 --- a/scripts/spo-add-fields-to-contenttypes/README.md +++ b/scripts/spo-add-fields-to-contenttypes/README.md @@ -94,100 +94,159 @@ finally { # [CLI for Microsoft 365](#tab/cli-m365-ps) ```powershell +# .\Add-FieldsToContentTypes.ps1 -SiteUrl "https://contoso.sharepoint.com/sites/CLIForM365" -ContentTypes "My Review CT","Global User Review CT" -WhatIf +[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] +param ( + [Parameter(Mandatory = $true, HelpMessage = "Absolute URL of the site where the fields and content types exist.")] + [ValidatePattern('^https://')] + [string]$SiteUrl, + + [Parameter(Mandatory = $true, HelpMessage = "Content type names to which the fields should be added.")] + [ValidateNotNullOrEmpty()] + [string[]]$ContentTypes, + + [Parameter(HelpMessage = "Optional override for the field definitions.")] + [ValidateNotNull()] + [System.Collections.Hashtable[]]$FieldDefinitions +) + +begin { + Write-Verbose "Ensuring CLI for Microsoft 365 session." + m365 login --ensure + + if (-not $FieldDefinitions) { + $FieldDefinitions = @( + @{ FieldName = 'admin_review'; FieldId = '3eccccb1-9789-40e9-bee8-0e27a2b0ea9f'; FieldXml = "