Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 将自定义webtemplate应用于网站集在powershell ise上工作,而不是在powershell控制台上工作_Sharepoint_Powershell_Powershell Ise - Fatal编程技术网

Sharepoint 将自定义webtemplate应用于网站集在powershell ise上工作,而不是在powershell控制台上工作

Sharepoint 将自定义webtemplate应用于网站集在powershell ise上工作,而不是在powershell控制台上工作,sharepoint,powershell,powershell-ise,Sharepoint,Powershell,Powershell Ise,我正在开发一个用于部署sharepoint项目的自动化脚本。我使用的是沙箱级webtemplate,在创建de站点时必须应用该模板。我在这方面遇到了很多麻烦,因为sharepoint似乎会缓存webtemplates列表,而get-spwebtemplate却找不到新添加的模板。我的工作方式是: [system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") $site= new-Object Microsoft

我正在开发一个用于部署sharepoint项目的自动化脚本。我使用的是沙箱级webtemplate,在创建de站点时必须应用该模板。我在这方面遇到了很多麻烦,因为sharepoint似乎会缓存webtemplates列表,而get-spwebtemplate却找不到新添加的模板。我的工作方式是:

[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")
$site= new-Object Microsoft.SharePoint.SPSite($web_application_complete_url)
$site.OpenWeb().ApplyWebTemplate($web_template_name)
$site.Dispose()
如您所见,我使用的是.net sharepoint api而不是cmdlet。这在PowerShell ISE中运行良好,但在PowerShell控制台中,它会引发一个有关引用DLL的异常:

使用“1”参数调用“ApplyWebTemplate”时出现异常:“无法加载文件。” 或程序集“XXX.SharePoint.Common,版本=1.0.0.0,区域性=中性,PublicK” eyToken=534c125b45123456'或其依赖项之一。系统找不到 指定了一个文件。“ 在C:\Build\SharePointBuild.p s1:318字符:37
+$site.OpenWeb().ApplyWebTemplate是否有可能运行64位ISE和32位PowerShell控制台(反之亦然)?如果不是这样,那么另一个区别是ISE在COM STA模式下运行,而PowerShell控制台默认在MTA模式下运行。这只有在SharePoint在幕后使用COM时才重要(我认为它确实如此)。您可以通过在STA模式下运行PowerShell控制台来验证这一点,如下所示:

C:\> Start-Process PowerShell -arg -sta

假设您使用的是PowerShell 2.0启动进程cmdlet。

是否有可能运行64位ISE和32位PowerShell控制台(反之亦然)?如果不是这样,那么另一个区别是ISE在COM STA模式下运行,而PowerShell控制台默认在MTA模式下运行。这只有在SharePoint在幕后使用COM时才重要(我认为它确实如此)。您可以通过在STA模式下运行PowerShell控制台来验证这一点,如下所示:

C:\> Start-Process PowerShell -arg -sta

假设您使用的是PowerShell 2.0启动进程cmdlet。

谢谢您的回复!因为我有64和x86 powershell可执行文件,所以我认为它们都是64位的。我在打开powershell时尝试了-sta参数,但它不起作用。但是,我将尝试您的方法在这种情况下,您可以尝试使用Windows SDK中的fuslogvw.exe工具。它将显示有关程序集加载失败的更多信息。这里有一个关于如何使用此工具的帮助主题:感谢您的回复!因为我有64和x86 powershell可执行文件,所以我认为它们都是64位的。我在打开powershell时尝试了-sta参数,但它不起作用。但是,我将尝试您的方法在这种情况下,您可以尝试使用Windows SDK中的fuslogvw.exe工具。它将显示有关程序集加载失败的更多信息。以下是有关如何使用此工具的帮助主题: