Last active
February 28, 2024 12:19
-
-
Save janikvonrotz/5749501 to your computer and use it in GitHub Desktop.
PowerShell: Get SharePoint Site Collection Objects
#PowerShell
#SharePoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-SPsite -Limit all | %{ | |
| $_ | Get-SPWeb -Limit all | %{ | |
| $_.Lists | %{ | |
| $_ | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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($_) | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $SPWebs = Get-SPsite -Limit All | Get-SPWeb -Limit All -ErrorAction SilentlyContinue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (Get-SPSite "http://sharepoint.domain.ch").AllWebs | select -expand Alerts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $SPSiteFilter = "http://sharepoint.domain.ch" | |
| Get-SPSite | where{$SPSiteFilter -contains $_.Url} | Get-SPWeb -Limit All | %{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment