janikvonrotz
6/10/2013 - 3:08 PM

PowerShell: Get SharePoint Site Collection Objects #PowerShell #SharePoint

PowerShell: Get SharePoint Site Collection Objects #PowerShell #SharePoint

$SPSiteFilter = "http://sharepoint.domain.ch"
Get-SPSite | where{$SPSiteFilter -contains $_.Url} | Get-SPWeb -Limit All | %{}
$SPUrl = (Get-SPUrl $Identity).Url

$SPWeb = Get-SPWeb $SPUrl

if($IncludeChildItems -and -not $Recursive){

    $SPWebs += $SPWeb
    $SPWebs += $SPWeb.webs            

}elseif($Recursive -and -not $IncludeChildItems){

    $SPWebs = $SPWeb.Site.AllWebs | where{$_.Url.Startswith($SPWeb.Url)}
    
}else{

    $SPWeb = Get-SPWeb -Identity $SPWebUrl.OriginalString
    $SPWebs += $SPWeb
} 
(Get-SPSite "http://sharepoint.domain.ch").AllWebs | select -expand Alerts
$SPWebs = Get-SPsite -Limit All | Get-SPWeb -Limit All -ErrorAction SilentlyContinue
Get-SPSite | Get-SPWeb -Limit All | %{

    $SPWeb = $_
    [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($_) | %{
        
        $SPPublishingWeb = $_
        $SPWeb.GetLimitedWebPartManager("$($_.Uri)$($_.DefaultPage)", [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) | %{
        
            $SPWebPartManager = $_
            
            $_.WebParts | %{
            
                # do something
                
                $SPWebPartManager.SaveChanges($_)
            
            }                   
        }
    }
}
# Get all Webapplictons
$SPWebApps = Get-SPWebApplication

# Get all sites
$SPSites = $SPWebApp | Get-SPsite -Limit all 

foreach($SPSite in $SPSites){

  # Get all websites
  $SPWebs = $SPSite | Get-SPWeb -Limit all

  foreach ($SPWeb in $SPWebs){

    foreach($SPList in $SPweb.lists){

      $SPList | select title, DefaultViewUrl

    }
  }
}
Get-SPsite -Limit all | %{
    $_ |  Get-SPWeb -Limit all | %{
        $_.Lists | %{
            $_    
        }
    }
}