Add-SPOSiteDesignTask : Operation is not valid due to the current state of the object.

%3CLINGO-SUB%20id%3D%22lingo-sub-1186139%22%20slang%3D%22en-US%22%3EAdd-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1186139%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20created%20site%20design%20with%20two%20site%20scripts.%20applied%20using%20below%20command%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%233366FF%22%3E%24Sitedesignout1%3DAdd-SPOSiteDesign%20-Title%20%22Site%20Design%202%22%20-WebTemplate%20%2268%22%20-SiteScripts%20%24result1.Id%2C%24result2.Id%20-Description%20%22Site%20Desin%20Sample%22%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20after%20try%20to%20apply%20Site%20design%20using%20below%20code%20throwing%20an%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object%20error%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24adminSiteUrl%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Fmyadmin-admin.sharepoint.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmyadmin-admin.sharepoint.com%3C%2FA%3E%22%3C%2FP%3E%3CP%3E%24siteUrl%20%3D%20%22https%3A%2F%2F%20myadmin.sharepoint.com%2Fsites%2FPracticeSiteDesign%22%3C%2FP%3E%3CP%3E%24siteDesignId%20%3D%20%2204d0e647-5912-4ef7-8069-9186cebb2192%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnect-SPOService%20%24adminSiteUrl%3C%2FP%3E%3CP%3E%24task%20%3D%20Add-SPOSiteDesignTask%20-SiteDesignId%20%24siteDesignId%20-WebUrl%20%24siteUrl%3C%2FP%3E%3CP%3EAdd-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FP%3E%3CP%3EAt%20line%3A6%20char%3A9%3C%2FP%3E%3CP%3E%2B%20%24task%20%3D%20Add-SPOSiteDesignTask%20-SiteDesignId%20%24siteDesignId%20-WebUrl%20%24si%20...%3C%2FP%3E%3CP%3E%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%20NotSpecified%3A%20(%3A)%20%5BAdd-SPOSiteDesignTask%5D%2C%20ServerException%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.SharePoint.Client.ServerException%2CMicrosoft.Online.SharePoint.PowerShell.AddSPOSiteDesignTask%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1186139%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1187488%22%20slang%3D%22en-US%22%3ERe%3A%20Add-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1187488%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F208605%22%20target%3D%22_blank%22%3E%40Dinesh%20Bhat%3C%2FA%3E%26nbsp%3BI've%20historically%20encountered%20this%20same%20error%2C%20albeit%20not%20with%20the%20SPOSiteDesignTask%20cmdlet.%20Have%20you%20ensured%20that%20the%20site%20that%20you're%20trying%20to%20interact%20with%20is%20not%20being%20edited%20by%20anybody%20else%20at%20the%20time%20that%20the%20command%20is%20running%2C%20and%20that%20any%20pending%20changes%20have%20been%20published%3F%20Have%20you%20also%20encountered%20this%20same%20issue%20with%20different%20site%20designs%2C%20or%20is%20it%20only%20this%20site%20design%20which%20has%20been%20presenting%20issues%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1188123%22%20slang%3D%22en-US%22%3ERe%3A%20Add-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1188123%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F441017%22%20target%3D%22_blank%22%3E%40rowanhucklebridge%3C%2FA%3E%26nbsp%3B%2C%20Thanks%20for%20the%20reply.%20I%20have%20created%20new%20site%20without%20any%20additional%20content.%20So%20there%20is%20no%20pending%20changes%20and%20I%20am%20the%20only%20person%20having%20access%20to%20the%20site.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eif%20I%20create%20site%20design%20for%20each%20site%20script%20its%20working%20good.%20But%20only%20problem%20I%20need%20register%20multiple%20site%20design%20to%20tenant.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eif%20I%20combine%20site%20script%20and%20registered%20as%20one%20site%20design%2C%20throwing%20below%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20share%20your%20thought%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1190243%22%20slang%3D%22en-US%22%3ERe%3A%20Add-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1190243%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F208605%22%20target%3D%22_blank%22%3E%40Dinesh%20Bhat%3C%2FA%3E%26nbsp%3BI'm%20not%20sure%20how%20much%20help%20I%20can%20be%20here.%20Whenever%20I've%20previously%20received%20the%20same%20error%20message%20that%20you've%20been%20receiving%20-%20%22Operation%20is%20not%20valid%20due%20of%20the%20current%20state%20of%20the%20object%22%20-%20it%20usually%20means%20that%20whatever%20I%20am%20attempting%20to%20edit%20or%20modify%20cannot%20currently%20be%20modified%2C%20for%20instance%20if%20it%20is%20already%20undergoing%20edits%20or%20changes.%20So%20whilst%20I%20don't%20think%20I'm%20able%20to%20suggest%20a%20fix%20for%20you%2C%20I%20might%20be%20able%20to%20help%20diagnose%20where%20things%20are%20going%20wrong.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20this%20end%2C%20do%20you%20have%20multiple%20site%20scripts%20interact%20with%20the%20same%20sections%2Ffunctions%2Fareas%3F%20Could%20this%20be%20where%20the%20issue%20is%20coming%20from%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1458180%22%20slang%3D%22en-US%22%3ERe%3A%20Add-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1458180%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F441017%22%20target%3D%22_blank%22%3E%40rowanhucklebridge%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20each%20list%20is%20separate%20there%20is%20no%20connection.%20I%20have%20tried%20with%207%20list%20with%202%20site%20scripts%20it%20works%2C%20if%20i%20add%20one%20more%20site%20script%20below%20error%20throwing%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20large%20site%20with%20more%20than%2030%20list%20and%20library.%20So%20we%20have%20split%20into%204%20site%20scripts%20due%20to%20limit%20of%20100000%20characters.%20After%20we%20have%20added%204%20site%20scripts%20into%20site%20using%20below%20code%3C%2FP%3E%3CP%3EAdd-SPOSiteDesign%20%60%3CBR%20%2F%3E-Title%20%22My%20customer%20tracking%22%20%60%3CBR%20%2F%3E-WebTemplate%20%2264%22%20%60%3CBR%20%2F%3E-SiteScripts%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Escript1.id%2Cscript2.id%2Cscript3.id%2Cscript4.id%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%60%3CBR%20%2F%3E-Description%20%22Tracks%20key%20customer%20data%20in%20a%20list%22%20%60%3CBR%20%2F%3E-PreviewImageUrl%20%22%3CA%20href%3D%22https%3A%2F%2Fcontoso.sharepoint.com%2FSiteAssets%2Fsite-preview.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso.sharepoint.com%2FSiteAssets%2Fsite-preview.png%3C%2FA%3E%22%20%60%3CBR%20%2F%3E-PreviewImageAltText%20%22site%20preview%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20when%20we%20try%20to%20apply%26nbsp%3B%3CSTRONG%3EAdd-SPOSiteDesignTask%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ethrowing%20below%20error%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%22Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object%22%26nbsp%3B%20any%20idea%3F%20how%20to%20resolve%20or%20root%20cause%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1642684%22%20slang%3D%22en-US%22%3ERe%3A%20Add-SPOSiteDesignTask%20%3A%20Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1642684%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F208605%22%20target%3D%22_blank%22%3E%40Dinesh%20Bhat%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Dinesh%2C%20did%20you%20ever%20find%20a%20resolution%20for%20this%20issue%3F%20I%20am%20getting%20the%20same%20thing%2C%20I%20can%20split%20the%20scripts%20into%26nbsp%3B%20more%20site%20designs%20an%20it%20will%20work%20%2C%20but%20then%20I%20need%20to%20trigger%20multiple%20site%20designs.%20the%20only%20other%20option%20is%20to%20have%20azure%20run%20the%20scripts%2C%20but%20that%20involves%20a%20premium%20license%20for%20HTTP%20requests%20in%20flow.%20or%20setting%20up%20a%20datagatway%20server%20on%20premise%20to%20run%20the%20script.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I have created site design with two site scripts. applied using below command

$Sitedesignout1=Add-SPOSiteDesign -Title "Site Design 2" -WebTemplate "68" -SiteScripts $result1.Id,$result2.Id -Description "Site Desin Sample"

 

But after try to apply Site design using below code throwing an Operation is not valid due to the current state of the object error

 

$adminSiteUrl = "https://myadmin-admin.sharepoint.com"

$siteUrl = "https:// myadmin.sharepoint.com/sites/PracticeSiteDesign"

$siteDesignId = "04d0e647-5912-4ef7-8069-9186cebb2192"

 

Connect-SPOService $adminSiteUrl

$task = Add-SPOSiteDesignTask -SiteDesignId $siteDesignId -WebUrl $siteUrl

Add-SPOSiteDesignTask : Operation is not valid due to the current state of the object.

At line:6 char:9

+ $task = Add-SPOSiteDesignTask -SiteDesignId $siteDesignId -WebUrl $si ...

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Add-SPOSiteDesignTask], ServerException

    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.AddSPOSiteDesignTask

 

5 Replies
Highlighted

@Dinesh Bhat I've historically encountered this same error, albeit not with the SPOSiteDesignTask cmdlet. Have you ensured that the site that you're trying to interact with is not being edited by anybody else at the time that the command is running, and that any pending changes have been published? Have you also encountered this same issue with different site designs, or is it only this site design which has been presenting issues?

 

Hope this helps!

Highlighted

@rowanhucklebridge , Thanks for the reply. I have created new site without any additional content. So there is no pending changes and I am the only person having access to the site. 

 

if I create site design for each site script its working good. But only problem I need register multiple site design to tenant.

 

if I combine site script and registered as one site design, throwing below error.

 

Please share your thought 

 

 

Highlighted

@Dinesh Bhat I'm not sure how much help I can be here. Whenever I've previously received the same error message that you've been receiving - "Operation is not valid due of the current state of the object" - it usually means that whatever I am attempting to edit or modify cannot currently be modified, for instance if it is already undergoing edits or changes. So whilst I don't think I'm able to suggest a fix for you, I might be able to help diagnose where things are going wrong.

 

To this end, do you have multiple site scripts interact with the same sections/functions/areas? Could this be where the issue is coming from?

Highlighted

@rowanhucklebridge 

Thanks, each list is separate there is no connection. I have tried with 7 list with 2 site scripts it works, if i add one more site script below error throwing 

We have large site with more than 30 list and library. So we have split into 4 site scripts due to limit of 100000 characters. After we have added 4 site scripts into site using below code

Add-SPOSiteDesign `
-Title "My customer tracking" `
-WebTemplate "64" `
-SiteScripts script1.id,script2.id,script3.id,script4.id `
-Description "Tracks key customer data in a list" `
-PreviewImageUrl "https://contoso.sharepoint.com/SiteAssets/site-preview.png" `
-PreviewImageAltText "site preview"

 

After when we try to apply Add-SPOSiteDesignTask throwing below error 

 

"Operation is not valid due to the current state of the object"  any idea? how to resolve or root cause

 

Highlighted

@Dinesh Bhat 

 

Hi Dinesh, did you ever find a resolution for this issue? I am getting the same thing, I can split the scripts into  more site designs an it will work , but then I need to trigger multiple site designs. the only other option is to have azure run the scripts, but that involves a premium license for HTTP requests in flow. or setting up a datagateway server on premise to run the script. 

 

 

Cheers

**update**

I am getting the same issue running via Azure runbook as well.  the only options i will be left with is adding the site design task via RestApi if i want to keep the large site design. or split to many site designs( as that works). Any help with this would be appreciated.

 

cheers