Get-SPOWEbList.ps1
############################## #.SYNOPSIS #Get all lists from a specific site, sites, or root web context # #.DESCRIPTION #Initializes and returns all lists from a specific site, site of sites, or root site of a supplied context. # #.PARAMETER context #The context of the root web to return the lists from. # #.PARAMETER Web #The site(s) to return the lists from. # #.EXAMPLE #Get-SPOWebLists -Webs $Context.Web.Webs # #Get-SPOWebLists -Context $Context. # #.NOTES #Rename to get SPOWebList. Allow for targetet list retrieval, e.g. supply a name or id and return one list or multiples if multiple values are passed. ############################## function Get-SPOWebList { [CmdletBinding()] Param( [Parameter(ParameterSetname="context",Mandatory=$true,ValueFromPipeline)] [Microsoft.SharePoint.Client.ClientRuntimeContext] $Context = $Global:SPOCSOMContext, [Parameter(ParameterSetName="web",Mandatory=$true,ValueFromPipeline)] [Microsoft.SharePoint.Client.Web[]] $Webs ) Begin{ } Process{ #Get the lists from the site(s) or Context if($webs){ [Microsoft.SharePoint.Client.List[]]$results = @() Write-Verbose -Message "Web supplied. Getting Lists." foreach($w in $webs){ $results += Initialize-SPOCSOMCollections -CSOMCollection $w.Lists -ReturnObject } } else{ Write-Verbose -Message "Context Supplied. Getting lists from root web." $results = Initialize-SPOCSOMCollections -CSOMCollection $Context.Web.Lists -ReturnObject } #return the lists. Return ,$results } End{ } } |