Connect to SharePoint Online site list site content
Simple script to connect to a SharePoint Online site and retrieve some the content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
$SiteURL= "https://company.sharepoint.com/sites/AAA/BBB/CCCC" $UserName= "yourname@company.com" $Password = "password" $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force $Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword #connect to sharepoint online site using powershell Connect-PnPOnline -Url $SiteURL -Credentials $Cred $context = Get-PnPContext $web = $context.Web $context.load($web) Write-host ($web) $siteLists = Get-PnPList | Where-Object {$_.Hidden -eq $false} foreach($list in $siteLists){ $tenantListTitle = $list.Title write-host ($tenantListTitle) } |