I need to script all documents in a site library. I am site admin on each of the sites in the site collection but I am not site collection admin/SharePoint tenant admin.
I tried with the Sharepoint online module for PS first, but it looks like I would have needed tenant admin. Then I tried with CSOM and PnP, but none of them worked.
Can you provide a PS script or link in order to connect to my site (while being just site admin not site collection admin), in order to pick up libraries/lists etc from there?
The last script that I used :
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" <br/> Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" $SiteUrl="https://contoso.sharepoint.com/sites/MyRootSiteName" #credential $UserName="emailAddress@Contoso.com" $Password ="Passwrd" #Create Credential object from given user name and password $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force)) #Set up the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) $Ctx.Credentials = $Cred #Get the Web Object $Web = $Ctx.web $Ctx.Load($Web) $Ctx.ExecuteQuery()
The error that I got at the last line is:
Exception calling "ExecuteQuery" with "0" argument(s): "The sign-in name or password does not match one in the Microsoft account system."
Please let me know if I can connect to SP online via PS as only site admin and be able to script libary files.