The following example shows how to get a list of SharePoint lists and libraries on a SharePoint site. To display such a list, a custom function is needed:
The preceding function receives SPWeb
as the object and then invokes the appropriate functions from SharePoint API to retrieve lists (only those available on the Quick Launch menu).
To call this function, type the following:
The Get-SPSite
cmdlet lists all site collections (SPSite
), pipes the results to Get-SPWeb
that lists every site (SPWeb
) within the site collection. Finally Get-SPList
lists every list (only visible lists; system lists are usually hidden) in each of the sites found. The "-Limit ALL"
parameter is optional and should not be switched on for large farms. To display only lists within a single site, use the following code: