错误:调用"GetLimitedWebPartManager"的异常;带有"1"的参数:“无效的URL参数". - 电源外壳 [英] Error: Exception calling "GetLimitedWebPartManager" with "1" argument(s): "Invalid URL argument." - Powershell
本文介绍了错误:调用"GetLimitedWebPartManager"的异常;带有"1"的参数:“无效的URL参数". - 电源外壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查找是否在整个站点的任何其他页面中添加了特定的Web部件.我遍历Web应用程序,然后进入站点和页面.我使用了以下代码:
I am trying to find if a particular web part is added in any of ther pages across site. I am looping through web application, and then into the site and in the pages. I have used the below code:
$WebApps=Get-SPWebApplication
foreach($webApp in $WebApps)
{
foreach ($SPsite in $webApp.Sites) {
Get-SPSite $SPsite| % {
foreach ($web in $_.AllWebs){
$sitepages = [Microsoft.Sharepoint.Utilities.SpUtility]::GetLocalizedString('$Resources:WikiLibDefaultTitle',"core",$web.UICulture.LCID)
$pages = $null
$pages = $web.Lists[$sitepages]
if ($pages){
foreach ($file in $pages.Items) {
$fileUrl = $web.Url + "/" + $file.File.Url
$manager = $file.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
$webparts = $manager.webparts
$webparts | %{
ac $logfile "$fileUrl, $($_.DisplayTitle), $($_.GetType().ToString()), $($_.IsVisible)"
if ($_.DisplayTitle -match $WP -and -not [string]::IsNullOrEmpty($WP)){
ac $logfilewp "$fileUrl, $($_.DisplayTitle), $($_.GetType().ToString()), $($_.IsVisible)"
$logfilecontrol = 1
}
}
}
}
}
}
}
我收到错误消息
Exception calling "GetLimitedWebPartManager" with "1" argument(s): "Invalid URL argument."
At
+ $manager = $file.file.GetLimitedWebPartManager([System.Web.U ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SPException
Exception calling "GetLimitedWebPartManager" with "1" argument(s): "The file http://site/SitePages/New1.aspx does not exist."
+ $manager = $file.file.GetLimitedWebPartManager([System.W ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
该如何解决?
谢谢
推荐答案
您好,Venkatzeus,
您应该逐步调试代码.
首先,您可以在代码中检查大括号匹配.
然后您可以检查PowerShell脚本中的变量是否不为空.
您还可以根据下面的文章调试PowerShell脚本.
如何调试powershell脚本.
http://www.sharepoint-journey.com/debug-powershell-scripts. html
下面有一个用于获取页面信息的演示,其中包含特定的Web部件供您参考.
WP =内容搜索"
WP="Content Search"
logfile ="C:\ test \ logfile.txt"
logfile="C:\test\logfile.txt"
这篇关于错误:调用"GetLimitedWebPartManager"的异常;带有"1"的参数:“无效的URL参数". - 电源外壳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文