Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

System.Reflection.TargetInvocationException,MyReport.ps1

$
0
0

I have a little PowerShell script that runs fine of some farms but generates the error: System.Reflection.TargetInvocationException on other farms.

In both cases the script is run under the farm admin account from the SharePoint Admin PowerShell. Any idea why this would happen on some of the farms? Could the size of a the farm be a factor?

$count = 0L
$totalSize = 0L
$doclibs = 0L

$WebApplications = Get-SPWebApplication
foreach ($webApp in $WebApplications)
{
  foreach ($site in $webApp.Sites)
  {
    foreach ($web in $site.AllWebs)
	{
      foreach ($list in $web.Lists)
	  {
        if ($list.BaseType -eq "DocumentLibrary")
		{
          foreach ($item in $list.Items)
		  {
            $totalSize += $item.File.Length
            $count++

          }
		  $doclibs++
        }
      }
      $web.Dispose()
    }
    $site.Dispose()
  }
}

Error reported:

+ CategoryInfo          : NotSpecified: (:) [MyReport.ps1], TargetInvocationException+ FullyQualifiedErrorId : System.Reflection.TargetInvocationException,MyReport.ps1


Thanks!




Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>