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]
精彩评论