Category
Describe the bug
while applying a template, to a newly created tenant, the function was working perfectly, however it just decided to quit and throw an erorr
Steps to reproduce
`#File path of JSON file
$Last = $PSScriptRoot+"/"+ "AST.json"
#Give title to your Site Script
$LastTitle = "LAST"
#Tenant Url
$AdminURL = "https://-admin.sharepoint.com"
$flag = $true
$Content3= Get-Content $Last -Raw
$username = "admintenantname"
$Password = "Password"
$Password = ConvertTo-SecureString $Password -AsPlainText -Force;
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,$Password;
#Connect to Tenant Url
Connect-SPOService -Url $AdminURL -Credential $credentials
try{
$sitedesign3 = Get-SPOSiteDesign | where {$_.Title -eq $LastTitle}
Write-Host $sitedesign3.Id
Remove-SPOSiteDesign -Identity $sitedesign3.Id
}
catch{
Write-Output $.Exception.Message
$.Exception.Message | Out-File -FilePath Outlog.txt -Append
}
try
{
#Read the json file
$result3= Add-SPOSiteScript -Title $LastTitle -Content $Content3 #<------------error here
$Sitedesignout3= Add-SPOSiteDesign -Title $LastTitle -WebTemplate "68" -SiteScripts $result3.Id -Description $LastTitle
}
catch
{
Write-Output $.Exception.Message
$.Exception.Message | Out-File -FilePath GetSiteScriptLog.txt -Append
$flag =$false
}
`
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json", "actions": [ { "_comment" : "ALST Done", "verb": "createSPList", "listName": "LAST", "templateType": 101, "subactions": [ { "verb": "addSPLookupFieldXml", "schemaXml": "<Field Type=\"Lookup\" DisplayName=\"Document Type\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" ShowField=\"DocType\" UnlimitedLengthInDocumentLibrary=\"FALSE\" RelationshipDeleteBehavior=\"None\" ID=\"{4e4d8298-258e-4367-a6ff-1a62d5dc8e64}\" StaticName=\"Document_x0020_Type\" Name=\"Document_x0020_Type\" />", "targetListName": "Metadata" }, { "verb": "addSPFieldXml", "schemaXml": "<Field ID=\"{e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6}\" ReadOnly=\"TRUE\" Type=\"Computed\" Name=\"Combine\" DisplaceOnUpgrade=\"TRUE\" DisplayName=\"Merge\" Filterable=\"FALSE\" Sortable=\"FALSE\" Hidden=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"Combine\"><FieldRefs><FieldRef Name=\"FSObjType\" Key=\"Primary\" /><FieldRef Name=\"EncodedAbsUrl\" /><FieldRef Name=\"TemplateUrl\" /></FieldRefs><DisplayPattern><IfEqual><Expr1><Field Name=\"FSObjType\" /></Expr1><Expr2>0</Expr2><Then><HTML><![CDATA[<input id=\"chkCombine\" type=\"CHECKBOX\" title=\"Merge]]\" href=\"]]></HTML><Field Name=\"EncodedAbsUrl\" /><HTML><![CDATA[\">]]></HTML><HTML><![CDATA[<input id=\"chkUrl\" type=\"HIDDEN\" href=\"]]></HTML><Column Name=\"TemplateUrl\" HTMLEncode=\"TRUE\" /><HTML><![CDATA[\">]]></HTML><HTML><![CDATA[<input id=\"chkProgID\" type=\"HIDDEN\" href=\"]]></HTML><MapToControl><HTML>|</HTML><GetFileExtension><Column Name=\"TemplateUrl\" HTMLEncode=\"TRUE\" /></GetFileExtension></MapToControl><HTML><![CDATA[\">]]></HTML></Then></IfEqual></DisplayPattern></Field>" }, { "verb": "addSPFieldXml", "schemaXml": "<Field ID=\"{5d36727b-bcb2-47d2-a231-1f0bc63b7439}\" ReadOnly=\"TRUE\" Type=\"Computed\" Name=\"RepairDocument\" DisplaceOnUpgrade=\"TRUE\" DisplayName=\"Relink\" Filterable=\"FALSE\" Sortable=\"FALSE\" Hidden=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"RepairDocument\"><FieldRefs><FieldRef Name=\"FSObjType\" Key=\"Primary\" /><FieldRef Name=\"ID\" /></FieldRefs><DisplayPattern><IfEqual><Expr1><Field Name=\"FSObjType\" /></Expr1><Expr2>0</Expr2><Then><HTML><![CDATA[<input id=\"chkRepair\" type=\"CHECKBOX\" title=\"Relink\" docid=\"]]></HTML><Field Name=\"ID\" /><HTML><![CDATA[\">]]></HTML></Then></IfEqual></DisplayPattern></Field>" }, { "verb": "addSPView", "name": "All Documents", "viewFields": [ "DocIcon", "LinkFilename", "Document Type" ], "query": "<OrderBy><FieldRef Name=\"Modified\" Ascending=\"FALSE\" /></OrderBy>", "rowLimit": 30, "isPaged": true, "makeDefault": true, "scope": "Recursive", "formatterJSON": "" } ] } ] }
execute script on tenant.
Expected behavior
Should apply a site design to the admin site that is visible on a site within a site collection
Environment details (development & target environment)
- OS: Windows 10 Virtual Desktop
- Target Environment: SharePoint Online
- Framework:
Name Value
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
- Browser(s):. Chrome Version 81.0.4044.138 (Official Build) (64-bit)
- Tooling: Notepad++, Powershell
- Additional details: I have tried clearing browser cache, restarting the machine.
Thanks for your contribution! Sharing is caring.
Category
Describe the bug
while applying a template, to a newly created tenant, the function was working perfectly, however it just decided to quit and throw an erorr
Steps to reproduce
`#File path of JSON file
$Last = $PSScriptRoot+"/"+ "AST.json"
#Give title to your Site Script
$LastTitle = "LAST"
#Tenant Url
$AdminURL = "https://-admin.sharepoint.com"
$flag = $true
$Content3= Get-Content $Last -Raw
$username = "admintenantname"
$Password = "Password"
$Password = ConvertTo-SecureString $Password -AsPlainText -Force;
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,$Password;
#Connect to Tenant Url
Connect-SPOService -Url $AdminURL -Credential $credentials
try{
$sitedesign3 = Get-SPOSiteDesign | where {$_.Title -eq $LastTitle}
Write-Host $sitedesign3.Id
Remove-SPOSiteDesign -Identity $sitedesign3.Id
}
catch{
Write-Output $.Exception.Message
$.Exception.Message | Out-File -FilePath Outlog.txt -Append
}
try
{
#Read the json file
$result3= Add-SPOSiteScript -Title $LastTitle -Content $Content3 #<------------error here
$Sitedesignout3= Add-SPOSiteDesign -Title $LastTitle -WebTemplate "68" -SiteScripts $result3.Id -Description $LastTitle
}
catch
{
Write-Output $.Exception.Message
$.Exception.Message | Out-File -FilePath GetSiteScriptLog.txt -Append
$flag =$false
}
`
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json", "actions": [ { "_comment" : "ALST Done", "verb": "createSPList", "listName": "LAST", "templateType": 101, "subactions": [ { "verb": "addSPLookupFieldXml", "schemaXml": "<Field Type=\"Lookup\" DisplayName=\"Document Type\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" ShowField=\"DocType\" UnlimitedLengthInDocumentLibrary=\"FALSE\" RelationshipDeleteBehavior=\"None\" ID=\"{4e4d8298-258e-4367-a6ff-1a62d5dc8e64}\" StaticName=\"Document_x0020_Type\" Name=\"Document_x0020_Type\" />", "targetListName": "Metadata" }, { "verb": "addSPFieldXml", "schemaXml": "<Field ID=\"{e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6}\" ReadOnly=\"TRUE\" Type=\"Computed\" Name=\"Combine\" DisplaceOnUpgrade=\"TRUE\" DisplayName=\"Merge\" Filterable=\"FALSE\" Sortable=\"FALSE\" Hidden=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"Combine\"><FieldRefs><FieldRef Name=\"FSObjType\" Key=\"Primary\" /><FieldRef Name=\"EncodedAbsUrl\" /><FieldRef Name=\"TemplateUrl\" /></FieldRefs><DisplayPattern><IfEqual><Expr1><Field Name=\"FSObjType\" /></Expr1><Expr2>0</Expr2><Then><HTML><![CDATA[<input id=\"chkCombine\" type=\"CHECKBOX\" title=\"Merge]]\" href=\"]]></HTML><Field Name=\"EncodedAbsUrl\" /><HTML><![CDATA[\">]]></HTML><HTML><![CDATA[<input id=\"chkUrl\" type=\"HIDDEN\" href=\"]]></HTML><Column Name=\"TemplateUrl\" HTMLEncode=\"TRUE\" /><HTML><![CDATA[\">]]></HTML><HTML><![CDATA[<input id=\"chkProgID\" type=\"HIDDEN\" href=\"]]></HTML><MapToControl><HTML>|</HTML><GetFileExtension><Column Name=\"TemplateUrl\" HTMLEncode=\"TRUE\" /></GetFileExtension></MapToControl><HTML><![CDATA[\">]]></HTML></Then></IfEqual></DisplayPattern></Field>" }, { "verb": "addSPFieldXml", "schemaXml": "<Field ID=\"{5d36727b-bcb2-47d2-a231-1f0bc63b7439}\" ReadOnly=\"TRUE\" Type=\"Computed\" Name=\"RepairDocument\" DisplaceOnUpgrade=\"TRUE\" DisplayName=\"Relink\" Filterable=\"FALSE\" Sortable=\"FALSE\" Hidden=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"RepairDocument\"><FieldRefs><FieldRef Name=\"FSObjType\" Key=\"Primary\" /><FieldRef Name=\"ID\" /></FieldRefs><DisplayPattern><IfEqual><Expr1><Field Name=\"FSObjType\" /></Expr1><Expr2>0</Expr2><Then><HTML><![CDATA[<input id=\"chkRepair\" type=\"CHECKBOX\" title=\"Relink\" docid=\"]]></HTML><Field Name=\"ID\" /><HTML><![CDATA[\">]]></HTML></Then></IfEqual></DisplayPattern></Field>" }, { "verb": "addSPView", "name": "All Documents", "viewFields": [ "DocIcon", "LinkFilename", "Document Type" ], "query": "<OrderBy><FieldRef Name=\"Modified\" Ascending=\"FALSE\" /></OrderBy>", "rowLimit": 30, "isPaged": true, "makeDefault": true, "scope": "Recursive", "formatterJSON": "" } ] } ] }execute script on tenant.
Expected behavior
Should apply a site design to the admin site that is visible on a site within a site collection
Environment details (development & target environment)
Name Value
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Thanks for your contribution! Sharing is caring.