The best option is usually to assign insert options to standard values of your base template but if that is not an option, you can try something like:
$insertOptionToAdd = '{961227F1-2AC1-4346-B833-D9DBED0B7113}'
$items = Get-Item -Path master: -Query "/sitecore/content/Home/MyItems/* @@templatename ='My Template']"
$items | ForEach-Object {
$insertOptions = {$_["__Masters"].Split('|')}.Invoke()
if ($insertOptions[0] -eq "") {
$insertOptions.RemoveAt(0);
}
if (!$insertOptions.Contains($insertOptionToAdd)) {
$insertOptions.Add($insertOptionToAdd)
$newInsertOptions = [string]::Join("|",$insertOptions)
Write-Host "Updating Insert Options of " $_.ID " to:" $newInsertOptions
$_.Editing.BeginEdit();
$_["__Masters"] = $newInsertOptions;
$_.Editing.EndEdit();
}
}
(Backup your database before running)
__Standard values
?InsertOptions
from and added some different ones. This is why I can't just edit the templatestandardvalues
and reset the contentInsertOptions