本文介绍了通过Powershell从Page获取Webpart列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我想在页面中包含Webparts的目录中编写一个文本文件.

i want to write a Textfile in the directory with the Webparts they are included in Pages.

cls
$ csv_info =导入Csv c:\ temp \ Structure.txt-分隔符,"

cls
$csv_info = Import-Csv c:\temp\Structure.txt -delimiter ","

$ row = foreach($ csv_info中的$ line)
{

$row = foreach($line in $csv_info)
{

$ site =新对象Microsoft.SharePoint.SPSite("$($ line.URL)')
$ web = $ site.OpenWeb()

$site = New-Object Microsoft.SharePoint.SPSite("$($line.URL)")
$web = $site.OpenWeb()

if($ web.Language -eq"1031")
    {
       $ pages = $ web.GetList($ web.ServerRelativeUrl.TrimEnd('/')+"/Seiten")
    }
      
   其他
    {
    $ pages = $ web.GetList($ web.ServerRelativeUrl.TrimEnd('/')+"/Pages")
    }

if($web.Language -eq "1031")
    {
        $pages = $web.GetList($web.ServerRelativeUrl.TrimEnd('/') + "/Seiten")
    }
       
    else
    {
    $pages = $web.GetList($web.ServerRelativeUrl.TrimEnd('/') + "/Pages")
    }

   $ webUrl = $ web.Url.TrimEnd("/")
    foreach($ pages.Items中的$ item)
    {
       $ fileUrl = $ webUrl +"/"; + $ item.File.Url
      写主机$ fileUrl
       $ manager = $ site.GetLimitedWebPartManager($ fileUrl,[System.Web.UI.WebControls.Webparts.PersonalizationScope] :: Shared);
       $ manager.webparts |选择对象标题,ID {($ fileUrl)}
    } 
   
}
$ row |导出CSV-路径c:\ temp \ Webparts.txt

    $webUrl = $web.Url.TrimEnd("/")
    foreach ($item in $pages.Items)
    {
        $fileUrl = $webUrl + "/" + $item.File.Url
        Write-Host $fileUrl
        $manager = $site.GetLimitedWebPartManager($fileUrl,[System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
        $manager.webparts | select-object Title, ID,{($fileUrl)}
     } 
    
}
$row | Export-CSV -Path c:\temp\Webparts.txt

Pwershell的错误:

The error at Pwershell:

方法调用失败,因为[Microsoft.SharePoint.SPSite]不包含名为'GetLimitedWebPartManager'的方法.
在C:\ Documents and Settings \ yadwutschehor \ My Documents \ WindowsPowerShell \ Auslesen_Webparts_Globe_Export_with_SubSites_Page_URLs.ps1:28 ch
ar:50
+        $ manager = $ site.GetLimitedWebPartManager<<<< ($ fileUrl,[System.Web.UI.WebControls.Webparts.PersonalizationScope] :: Shared);
    + CategoryInfo         :InvalidOperation:(GetLimitedWebPartManager:String)[],RuntimeException
    + FullyQualifiedErrorId:MethodNotFound

Method invocation failed because [Microsoft.SharePoint.SPSite] doesn't contain a method named 'GetLimitedWebPartManager'.
At C:\Documents and Settings\yadwutschehor\My Documents\WindowsPowerShell\Auslesen_Webparts_Globe_Export_with_SubSites_Page_URLs.ps1:28 ch
ar:50
+         $manager = $site.GetLimitedWebPartManager <<<< ($fileUrl,[System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
    + CategoryInfo          : InvalidOperation: (GetLimitedWebPartManager:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

如何从SPSite获取Webpart信息?

How can i get the Webpart information from a SPSite?

感谢您的帮助

推荐答案

 

谢谢您的发帖!  ;我建议您在一个MS论坛中发布您的问题,

Thank you for your post!  I would suggest posting your question in one of the MS Forum,


这篇关于通过Powershell从Page获取Webpart列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!