sharepoint - Applying a custom webtemplate to a sitecollection works on powershell ise and not on powershell console -
i'm working on automated script deploying sharepoint projects. i'm using sandbox level webtemplate must applied when de site created. had lot of troubles doing because seems sharepoint caches list of webtemplates , get-spwebtemplate doens't find new added one. way made work this:
[system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint") $site= new-object microsoft.sharepoint.spsite($web_application_complete_url) $site.openweb().applywebtemplate($web_template_name) $site.dispose()
as can see, i'm using .net sharepoint api instead of cmdlets. works sweet in powershell ise in powershell console throws exception regarding referenced dll:
exception calling "applywebtemplate" "1" argument(s): "could not load file or assembly 'xxx.sharepoint.common, version=1.0.0.0, culture=neutral, publick eytoken=534c125b45123456' or 1 of dependencies. system cannot find th e file specified." @ c:\build\sharepointbuild.p s1:318 char:37 + $site.openweb().applywebtemplate <<<< ($web_template_name) + categoryinfo : notspecified: (:) [], parentcontainserrorrecorde xception + fullyqualifiederrorid : dotnetmethodexception
the assembly registered in gac when installing web template sandbox solution in sitecollection.
any ideas? thanks!
is there chance running 64-bit ise , 32-bit powershell console (or vice-versa)? if it's not difference ise runs in com sta mode whereas powershell console runs in mta default. matter if sharepoint uses com under covers (which think does). verify running powershell console in sta mode so:
c:\> start-process powershell -arg -sta
assuming you're on powershell 2.0 start-process cmdlet.
Comments
Post a Comment