我想使用powershell脚本在Web部件区域中添加Web部件

时间:2011-06-03 11:43:24

标签: sharepoint powershell web-parts

我只想使用 power shell脚本

以编程方式在Web部件区域中添加Web部件

我使用power shell脚本

获得此异常

异常代码

$webPart = $webpartmanager.ImportWebPart($xmlReader, $errorMsg) -as [Microsoft.SharePoint.WebPartPages.WebPart]



Argument: '2' should be a System.Management.Automation.PSReference. Use [ref].
+ $webPart = $webpartmanager.ImportWebPart <<<< ($xmlReader, $errorMsg) -as [Microsoft.SharePoint.WebPartPages.WebPart]
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : NonRefArgumentToRefParameterMsg

1 个答案:

答案 0 :(得分:0)

您是否尝试过错误消息的建议(请注意在[ref]之前添加$errorMsg)?

$webPart = $webpartmanager.ImportWebPart($xmlReader, [ref]$errorMsg)
               -as [Microsoft.SharePoint.WebPartPages.WebPart]