开发者

I want to add web part in web part zone using powershell script

I want to add web part in the web part zone programmatically only using power shell script

I am getting this exception using power shell scripting

Exception code

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



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


Have you tried what the error message suggests (note the addition of [ref] before $errorMsg)?

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜